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

from . import cachepubsub_pb2 as cachepubsub__pb2
import common_pb2 as common__pb2


class PubsubStub(object):
    """For working with topics in a cache.
    Momento topics are conceptually located on a cache. They are best-effort multicast.
    To use them, create a cache then start subscribing and publishing!

    Momento topic subscriptions try to give you information about the quality of the
    stream you are receiving. For example, you might miss messages if your network
    is slow, or if some intermediate switch fails, or due to rate limiting. It is
    also possible, though we try to avoid it, that messages could briefly come out
    of order between subscribers.
    We try to tell you when things like this happen via a Discontinuity in your
    subscription stream. If you do not care about occasional discontinuities then
    don't bother handling them! You might still want to log them just in case ;-)
    """

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

        Args:
            channel: A grpc.Channel.
        """
        self.Publish = channel.unary_unary(
                '/cache_client.pubsub.Pubsub/Publish',
                request_serializer=cachepubsub__pb2._PublishRequest.SerializeToString,
                response_deserializer=common__pb2._Empty.FromString,
                )
        self.Subscribe = channel.unary_stream(
                '/cache_client.pubsub.Pubsub/Subscribe',
                request_serializer=cachepubsub__pb2._SubscriptionRequest.SerializeToString,
                response_deserializer=cachepubsub__pb2._SubscriptionItem.FromString,
                )


class PubsubServicer(object):
    """For working with topics in a cache.
    Momento topics are conceptually located on a cache. They are best-effort multicast.
    To use them, create a cache then start subscribing and publishing!

    Momento topic subscriptions try to give you information about the quality of the
    stream you are receiving. For example, you might miss messages if your network
    is slow, or if some intermediate switch fails, or due to rate limiting. It is
    also possible, though we try to avoid it, that messages could briefly come out
    of order between subscribers.
    We try to tell you when things like this happen via a Discontinuity in your
    subscription stream. If you do not care about occasional discontinuities then
    don't bother handling them! You might still want to log them just in case ;-)
    """

    def Publish(self, request, context):
        """Publish a message to a topic.

        If a topic has no subscribers, then the effect of Publish MAY be either of:
        * It is dropped and the topic is nonexistent.
        * It is accepted to the topic as the next message.

        Publish() does not wait for subscribers to accept. It returns Ok upon accepting
        the topic value. It also returns Ok if there are no subscribers and the value
        happens to be dropped. Publish() can not guarantee delivery in theory but in
        practice it should almost always deliver to subscribers.

        REQUIRES HEADER authorization: Momento auth token
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')

    def Subscribe(self, request, context):
        """Subscribe to notifications from a topic.

        You will receive a stream of values and (hopefully occasional) discontinuities.
        Values will appear as copies of the payloads you Publish() to the topic.

        REQUIRES HEADER authorization: Momento auth token
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details('Method not implemented!')
        raise NotImplementedError('Method not implemented!')


def add_PubsubServicer_to_server(servicer, server):
    rpc_method_handlers = {
            'Publish': grpc.unary_unary_rpc_method_handler(
                    servicer.Publish,
                    request_deserializer=cachepubsub__pb2._PublishRequest.FromString,
                    response_serializer=common__pb2._Empty.SerializeToString,
            ),
            'Subscribe': grpc.unary_stream_rpc_method_handler(
                    servicer.Subscribe,
                    request_deserializer=cachepubsub__pb2._SubscriptionRequest.FromString,
                    response_serializer=cachepubsub__pb2._SubscriptionItem.SerializeToString,
            ),
    }
    generic_handler = grpc.method_handlers_generic_handler(
            'cache_client.pubsub.Pubsub', rpc_method_handlers)
    server.add_generic_rpc_handlers((generic_handler,))


 # This class is part of an EXPERIMENTAL API.
class Pubsub(object):
    """For working with topics in a cache.
    Momento topics are conceptually located on a cache. They are best-effort multicast.
    To use them, create a cache then start subscribing and publishing!

    Momento topic subscriptions try to give you information about the quality of the
    stream you are receiving. For example, you might miss messages if your network
    is slow, or if some intermediate switch fails, or due to rate limiting. It is
    also possible, though we try to avoid it, that messages could briefly come out
    of order between subscribers.
    We try to tell you when things like this happen via a Discontinuity in your
    subscription stream. If you do not care about occasional discontinuities then
    don't bother handling them! You might still want to log them just in case ;-)
    """

    @staticmethod
    def Publish(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, '/cache_client.pubsub.Pubsub/Publish',
            cachepubsub__pb2._PublishRequest.SerializeToString,
            common__pb2._Empty.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

    @staticmethod
    def Subscribe(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_stream(request, target, '/cache_client.pubsub.Pubsub/Subscribe',
            cachepubsub__pb2._SubscriptionRequest.SerializeToString,
            cachepubsub__pb2._SubscriptionItem.FromString,
            options, channel_credentials,
            insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
