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

from hatchet_sdk.contracts.v1 import dispatcher_pb2 as v1_dot_dispatcher__pb2

GRPC_GENERATED_VERSION = '1.76.0'
GRPC_VERSION = grpc.__version__
_version_not_supported = False

try:
    from grpc._utilities import first_version_is_lower
    _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
except ImportError:
    _version_not_supported = True

if _version_not_supported:
    raise RuntimeError(
        f'The grpc package installed is at version {GRPC_VERSION},'
        + ' but the generated code in v1/dispatcher_pb2_grpc.py depends on'
        + f' grpcio>={GRPC_GENERATED_VERSION}.'
        + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
        + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
    )


class V1DispatcherStub(object):
    """Missing associated documentation comment in .proto file."""

    def __init__(self, channel: grpc.Channel | grpc.aio.Channel) -> None:
        """Constructor.

        Args:
            channel: A grpc.Channel.
        """
        self.DurableTask = channel.stream_stream(
                '/v1.V1Dispatcher/DurableTask',
                request_serializer=v1_dot_dispatcher__pb2.DurableTaskRequest.SerializeToString,
                response_deserializer=v1_dot_dispatcher__pb2.DurableTaskResponse.FromString,
                _registered_method=True)
        self.RegisterDurableEvent = channel.unary_unary(
                '/v1.V1Dispatcher/RegisterDurableEvent',
                request_serializer=v1_dot_dispatcher__pb2.RegisterDurableEventRequest.SerializeToString,
                response_deserializer=v1_dot_dispatcher__pb2.RegisterDurableEventResponse.FromString,
                _registered_method=True)
        self.ListenForDurableEvent = channel.stream_stream(
                '/v1.V1Dispatcher/ListenForDurableEvent',
                request_serializer=v1_dot_dispatcher__pb2.ListenForDurableEventRequest.SerializeToString,
                response_deserializer=v1_dot_dispatcher__pb2.DurableEvent.FromString,
                _registered_method=True)


class V1DispatcherServicer(object):
    """Missing associated documentation comment in .proto file."""

    def DurableTask(self, request_iterator, context):
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def RegisterDurableEvent(self, request, context):
        """NOTE: deprecated after DurableEventLog is implemented
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def ListenForDurableEvent(self, request_iterator, context):
        """Missing associated documentation comment in .proto file."""
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_V1DispatcherServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'DurableTask': grpc.stream_stream_rpc_method_handler(
                    servicer.DurableTask,
                    request_deserializer=v1_dot_dispatcher__pb2.DurableTaskRequest.FromString,
                    response_serializer=v1_dot_dispatcher__pb2.DurableTaskResponse.SerializeToString,
            ),
            'RegisterDurableEvent': grpc.unary_unary_rpc_method_handler(
                    servicer.RegisterDurableEvent,
                    request_deserializer=v1_dot_dispatcher__pb2.RegisterDurableEventRequest.FromString,
                    response_serializer=v1_dot_dispatcher__pb2.RegisterDurableEventResponse.SerializeToString,
            ),
            'ListenForDurableEvent': grpc.stream_stream_rpc_method_handler(
                    servicer.ListenForDurableEvent,
                    request_deserializer=v1_dot_dispatcher__pb2.ListenForDurableEventRequest.FromString,
                    response_serializer=v1_dot_dispatcher__pb2.DurableEvent.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'v1.V1Dispatcher', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('v1.V1Dispatcher', rpc_method_handlers)


 # This class is part of an EXPERIMENTAL API.
class V1Dispatcher(object):
    """Missing associated documentation comment in .proto file."""

    @staticmethod
    def DurableTask(request_iterator,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.stream_stream(
            request_iterator,
            target,
            '/v1.V1Dispatcher/DurableTask',
            v1_dot_dispatcher__pb2.DurableTaskRequest.SerializeToString,
            v1_dot_dispatcher__pb2.DurableTaskResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def RegisterDurableEvent(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,
            '/v1.V1Dispatcher/RegisterDurableEvent',
            v1_dot_dispatcher__pb2.RegisterDurableEventRequest.SerializeToString,
            v1_dot_dispatcher__pb2.RegisterDurableEventResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def ListenForDurableEvent(request_iterator,
            target,
            options=(),
            channel_credentials=None,
            call_credentials=None,
            insecure=False,
            compression=None,
            wait_for_ready=None,
            timeout=None,
            metadata=None):
        return grpc.experimental.stream_stream(
            request_iterator,
            target,
            '/v1.V1Dispatcher/ListenForDurableEvent',
            v1_dot_dispatcher__pb2.ListenForDurableEventRequest.SerializeToString,
            v1_dot_dispatcher__pb2.DurableEvent.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
