# 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 google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
from pynumaflow.proto.sourcer import source_pb2 as pynumaflow_dot_proto_dot_sourcer_dot_source__pb2

GRPC_GENERATED_VERSION = '1.75.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},'
        + f' but the generated code in pynumaflow/proto/sourcer/source_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 SourceStub(object):
    """Missing associated documentation comment in .proto file."""

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

        Args:
            channel: A grpc.Channel.
        """
        self.ReadFn = channel.stream_stream(
                '/source.v1.Source/ReadFn',
                request_serializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.ReadRequest.SerializeToString,
                response_deserializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.ReadResponse.FromString,
                _registered_method=True)
        self.AckFn = channel.stream_stream(
                '/source.v1.Source/AckFn',
                request_serializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.AckRequest.SerializeToString,
                response_deserializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.AckResponse.FromString,
                _registered_method=True)
        self.NackFn = channel.unary_unary(
                '/source.v1.Source/NackFn',
                request_serializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.NackRequest.SerializeToString,
                response_deserializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.NackResponse.FromString,
                _registered_method=True)
        self.PendingFn = channel.unary_unary(
                '/source.v1.Source/PendingFn',
                request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
                response_deserializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.PendingResponse.FromString,
                _registered_method=True)
        self.PartitionsFn = channel.unary_unary(
                '/source.v1.Source/PartitionsFn',
                request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
                response_deserializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.PartitionsResponse.FromString,
                _registered_method=True)
        self.IsReady = channel.unary_unary(
                '/source.v1.Source/IsReady',
                request_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
                response_deserializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.ReadyResponse.FromString,
                _registered_method=True)


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

    def ReadFn(self, request_iterator, context):
        """Read returns a stream of datum responses.
        The size of the returned responses is less than or equal to the num_records specified in each ReadRequest.
        If the request timeout is reached on the server side, the returned responses will contain all the datum that have been read (which could be an empty list).
        The server will continue to read and respond to subsequent ReadRequests until the client closes the stream.
        Once it has sent all the datum, the server will send a ReadResponse with the end of transmission flag set to true.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def AckFn(self, request_iterator, context):
        """AckFn acknowledges a stream of datum offsets.
        When AckFn is called, it implicitly indicates that the datum stream has been processed by the source vertex.
        The caller (numa) expects the AckFn to be successful, and it does not expect any errors.
        If there are some irrecoverable errors when the callee (UDSource) is processing the AckFn request,
        then it is best to crash because there are no other retry mechanisms possible.
        Clients sends n requests and expects n responses.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def NackFn(self, request, context):
        """NackFn negatively acknowledges a batch of offsets. Invoked during a critical error in the monovertex or pipeline.
        Unlike AckFn its not a streaming rpc because this is only invoked when there is a critical error (error path).
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def PendingFn(self, request, context):
        """PendingFn returns the number of pending records at the user defined source.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def PartitionsFn(self, request, context):
        """PartitionsFn returns the list of partitions for the user defined source.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def IsReady(self, request, context):
        """IsReady is the heartbeat endpoint for user defined source gRPC.
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_SourceServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'ReadFn': grpc.stream_stream_rpc_method_handler(
                    servicer.ReadFn,
                    request_deserializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.ReadRequest.FromString,
                    response_serializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.ReadResponse.SerializeToString,
            ),
            'AckFn': grpc.stream_stream_rpc_method_handler(
                    servicer.AckFn,
                    request_deserializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.AckRequest.FromString,
                    response_serializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.AckResponse.SerializeToString,
            ),
            'NackFn': grpc.unary_unary_rpc_method_handler(
                    servicer.NackFn,
                    request_deserializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.NackRequest.FromString,
                    response_serializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.NackResponse.SerializeToString,
            ),
            'PendingFn': grpc.unary_unary_rpc_method_handler(
                    servicer.PendingFn,
                    request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
                    response_serializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.PendingResponse.SerializeToString,
            ),
            'PartitionsFn': grpc.unary_unary_rpc_method_handler(
                    servicer.PartitionsFn,
                    request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
                    response_serializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.PartitionsResponse.SerializeToString,
            ),
            'IsReady': grpc.unary_unary_rpc_method_handler(
                    servicer.IsReady,
                    request_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
                    response_serializer=pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.ReadyResponse.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'source.v1.Source', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))
    server.add_registered_method_handlers('source.v1.Source', rpc_method_handlers)


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

    @staticmethod
    def ReadFn(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,
            '/source.v1.Source/ReadFn',
            pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.ReadRequest.SerializeToString,
            pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.ReadResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def AckFn(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,
            '/source.v1.Source/AckFn',
            pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.AckRequest.SerializeToString,
            pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.AckResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def NackFn(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,
            '/source.v1.Source/NackFn',
            pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.NackRequest.SerializeToString,
            pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.NackResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def PendingFn(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,
            '/source.v1.Source/PendingFn',
            google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
            pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.PendingResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def PartitionsFn(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,
            '/source.v1.Source/PartitionsFn',
            google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
            pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.PartitionsResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)

    @staticmethod
    def IsReady(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,
            '/source.v1.Source/IsReady',
            google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
            pynumaflow_dot_proto_dot_sourcer_dot_source__pb2.ReadyResponse.FromString,
            options,
            channel_credentials,
            insecure,
            call_credentials,
            compression,
            wait_for_ready,
            timeout,
            metadata,
            _registered_method=True)
