import logging
import grpc
import protobuf.sentiment_analysis_pb2_grpc as sentiment_pb2_grpc
import protobuf.named_entity_recognition_pb2_grpc as ner_pb2_grpc

import sentiment_server
import ner_server


async def serve() -> None:
  server = grpc.aio.server()
  
  sentiment_pb2_grpc.add_SentimentAnalyzerServicer_to_server(
    sentiment_server.SentimentServer(), server
  )
  ner_pb2_grpc.add_NamedEntityRecognizerServicer_to_server(
    ner_server.NamedEntityRecognizerServer(), server
  )

  listen_addr = '[::]:50051'
  server.add_insecure_port(listen_addr)
  await server.start()
  logging.info(f'Serving on {listen_addr}')
  await server.wait_for_termination()