# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc

from . import wc_pb2 as wc__pb2


class WordCountServiceStub(object):
    """WordCountService services word counting based on WordCountRequest message.
    * Note on caching:
    - The implementation of this service may contain internal caching on
    HTML document.
    - Request multiple word count in a single uri rather than calling
    any services multiple times.
    """

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

        Args:
          channel: A grpc.Channel.
        """
        self.CountWords = channel.unary_stream(
            "/WordCountService/CountWords",
            request_serializer=wc__pb2.WordCountRequest.SerializeToString,
            response_deserializer=wc__pb2.WordCount.FromString,
        )


class WordCountServiceServicer(object):
    """WordCountService services word counting based on WordCountRequest message.
    * Note on caching:
    - The implementation of this service may contain internal caching on
    HTML document.
    - Request multiple word count in a single uri rather than calling
    any services multiple times.
    """

    def CountWords(self, request, context):
        """Service each word's occurrence in a certain uri.
        If error happens, it will cut a stream and send gRPC error code with
        detailed message instead of WordCount stream
        """
        context.set_code(grpc.StatusCode.UNIMPLEMENTED)
        context.set_details("Method not implemented!")
        raise NotImplementedError("Method not implemented!")


def add_WordCountServiceServicer_to_server(servicer, server):
    rpc_method_handlers = {
        "CountWords": grpc.unary_stream_rpc_method_handler(
            servicer.CountWords,
            request_deserializer=wc__pb2.WordCountRequest.FromString,
            response_serializer=wc__pb2.WordCount.SerializeToString,
        )
    }
    generic_handler = grpc.method_handlers_generic_handler(
        "WordCountService", rpc_method_handlers
    )
    server.add_generic_rpc_handlers((generic_handler,))
