# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

from angzarr_client.proto.angzarr import command_handler_pb2 as angzarr_dot_command__handler__pb2
from angzarr_client.proto.angzarr import types_pb2 as angzarr_dot_types__pb2


class CommandHandlerServiceStub(object):
    """CommandHandlerService: client logic that processes commands and emits events
    Business logic layer that implements command handling for a domain aggregate
    client logic doesn't care about sync - coordinator decides
    """

    def __init__(self, channel):
        """Constructor.

        Args:
            channel: A grpc.Channel.
        """
        self.Handle = channel.unary_unary(
                '/angzarr.CommandHandlerService/Handle',
                request_serializer=angzarr_dot_types__pb2.ContextualCommand.SerializeToString,
                response_deserializer=angzarr_dot_command__handler__pb2.BusinessResponse.FromString,
                _registered_method=True)
        self.Replay = channel.unary_unary(
                '/angzarr.CommandHandlerService/Replay',
                request_serializer=angzarr_dot_command__handler__pb2.ReplayRequest.SerializeToString,
                response_deserializer=angzarr_dot_command__handler__pb2.ReplayResponse.FromString,
                _registered_method=True)


class CommandHandlerServiceServicer(object):
    """CommandHandlerService: client logic that processes commands and emits events
    Business logic layer that implements command handling for a domain aggregate
    client logic doesn't care about sync - coordinator decides
    """

    def Handle(self, request, context):
        """Process command and return business response (events or revocation request)
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def Replay(self, request, context):
        """Replay events to compute state (for conflict detection)
        Optional: only needed if aggregate supports MERGE_COMMUTATIVE
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_CommandHandlerServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'Handle': grpc.unary_unary_rpc_method_handler(
                    servicer.Handle,
                    request_deserializer=angzarr_dot_types__pb2.ContextualCommand.FromString,
                    response_serializer=angzarr_dot_command__handler__pb2.BusinessResponse.SerializeToString,
            ),
            'Replay': grpc.unary_unary_rpc_method_handler(
                    servicer.Replay,
                    request_deserializer=angzarr_dot_command__handler__pb2.ReplayRequest.FromString,
                    response_serializer=angzarr_dot_command__handler__pb2.ReplayResponse.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'angzarr.CommandHandlerService', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('angzarr.CommandHandlerService', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class CommandHandlerService(object):
    """CommandHandlerService: client logic that processes commands and emits events
    Business logic layer that implements command handling for a domain aggregate
    client logic doesn't care about sync - coordinator decides
    """

    @staticmethod
    def Handle(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/angzarr.CommandHandlerService/Handle',
            angzarr_dot_types__pb2.ContextualCommand.SerializeToString,
            angzarr_dot_command__handler__pb2.BusinessResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def Replay(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/angzarr.CommandHandlerService/Replay',
            angzarr_dot_command__handler__pb2.ReplayRequest.SerializeToString,
            angzarr_dot_command__handler__pb2.ReplayResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)


class CommandHandlerCoordinatorServiceStub(object):
    """CommandHandlerCoordinatorService: orchestrates command processing for domain aggregates
    """

    def __init__(self, channel):
        """Constructor.

        Args:
            channel: A grpc.Channel.
        """
        self.HandleCommand = channel.unary_unary(
                '/angzarr.CommandHandlerCoordinatorService/HandleCommand',
                request_serializer=angzarr_dot_types__pb2.CommandRequest.SerializeToString,
                response_deserializer=angzarr_dot_command__handler__pb2.CommandResponse.FromString,
                _registered_method=True)
        self.HandleEvent = channel.unary_unary(
                '/angzarr.CommandHandlerCoordinatorService/HandleEvent',
                request_serializer=angzarr_dot_types__pb2.EventRequest.SerializeToString,
                response_deserializer=angzarr_dot_command__handler__pb2.FactInjectionResponse.FromString,
                _registered_method=True)
        self.HandleSyncSpeculative = channel.unary_unary(
                '/angzarr.CommandHandlerCoordinatorService/HandleSyncSpeculative',
                request_serializer=angzarr_dot_command__handler__pb2.SpeculateCommandHandlerRequest.SerializeToString,
                response_deserializer=angzarr_dot_command__handler__pb2.CommandResponse.FromString,
                _registered_method=True)
        self.HandleCompensation = channel.unary_unary(
                '/angzarr.CommandHandlerCoordinatorService/HandleCompensation',
                request_serializer=angzarr_dot_types__pb2.CommandRequest.SerializeToString,
                response_deserializer=angzarr_dot_command__handler__pb2.BusinessResponse.FromString,
                _registered_method=True)


class CommandHandlerCoordinatorServiceServicer(object):
    """CommandHandlerCoordinatorService: orchestrates command processing for domain aggregates
    """

    def HandleCommand(self, request, context):
        """Process command with optional sync mode (default: async fire-and-forget)
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def HandleEvent(self, request, context):
        """Inject fact events - external realities that cannot be rejected.
        Idempotent: subsequent requests with same external_id return original events.
        Use EventRequest.route_to_handler to control command handler invocation.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def HandleSyncSpeculative(self, request, context):
        """Speculative execution - execute against temporal state without persisting
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def HandleCompensation(self, request, context):
        """Compensation flow - returns BusinessResponse for saga compensation handling.
        If business returns events, persists them. Caller handles revocation flags.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_CommandHandlerCoordinatorServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'HandleCommand': grpc.unary_unary_rpc_method_handler(
                    servicer.HandleCommand,
                    request_deserializer=angzarr_dot_types__pb2.CommandRequest.FromString,
                    response_serializer=angzarr_dot_command__handler__pb2.CommandResponse.SerializeToString,
            ),
            'HandleEvent': grpc.unary_unary_rpc_method_handler(
                    servicer.HandleEvent,
                    request_deserializer=angzarr_dot_types__pb2.EventRequest.FromString,
                    response_serializer=angzarr_dot_command__handler__pb2.FactInjectionResponse.SerializeToString,
            ),
            'HandleSyncSpeculative': grpc.unary_unary_rpc_method_handler(
                    servicer.HandleSyncSpeculative,
                    request_deserializer=angzarr_dot_command__handler__pb2.SpeculateCommandHandlerRequest.FromString,
                    response_serializer=angzarr_dot_command__handler__pb2.CommandResponse.SerializeToString,
            ),
            'HandleCompensation': grpc.unary_unary_rpc_method_handler(
                    servicer.HandleCompensation,
                    request_deserializer=angzarr_dot_types__pb2.CommandRequest.FromString,
                    response_serializer=angzarr_dot_command__handler__pb2.BusinessResponse.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'angzarr.CommandHandlerCoordinatorService', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('angzarr.CommandHandlerCoordinatorService', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class CommandHandlerCoordinatorService(object):
    """CommandHandlerCoordinatorService: orchestrates command processing for domain aggregates
    """

    @staticmethod
    def HandleCommand(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/angzarr.CommandHandlerCoordinatorService/HandleCommand',
            angzarr_dot_types__pb2.CommandRequest.SerializeToString,
            angzarr_dot_command__handler__pb2.CommandResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def HandleEvent(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/angzarr.CommandHandlerCoordinatorService/HandleEvent',
            angzarr_dot_types__pb2.EventRequest.SerializeToString,
            angzarr_dot_command__handler__pb2.FactInjectionResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def HandleSyncSpeculative(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/angzarr.CommandHandlerCoordinatorService/HandleSyncSpeculative',
            angzarr_dot_command__handler__pb2.SpeculateCommandHandlerRequest.SerializeToString,
            angzarr_dot_command__handler__pb2.CommandResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def HandleCompensation(request,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.unary_unary(
            request,
            target,
            '/angzarr.CommandHandlerCoordinatorService/HandleCompensation',
            angzarr_dot_types__pb2.CommandRequest.SerializeToString,
            angzarr_dot_command__handler__pb2.BusinessResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
