예제 #1
0
 def create_data_channel(self, remote_grpc_port):
     url = remote_grpc_port.api_service_descriptor.url
     if url not in self._data_channel_cache:
         logging.info('Creating channel for %s', url)
         grpc_channel = grpc.insecure_channel(url)
         self._data_channel_cache[url] = GrpcClientDataChannel(
             beam_fn_api_pb2.BeamFnDataStub(grpc_channel))
     return self._data_channel_cache[url]
예제 #2
0
 def create_data_channel(self, function_spec):
   remote_grpc_port = beam_fn_api_pb2.RemoteGrpcPort()
   function_spec.data.Unpack(remote_grpc_port)
   url = remote_grpc_port.api_service_descriptor.url
   if url not in self._data_channel_cache:
     logging.info('Creating channel for %s', url)
     grpc_channel = grpc.insecure_channel(url)
     self._data_channel_cache[url] = GrpcClientDataChannel(
         beam_fn_api_pb2.BeamFnDataStub(grpc_channel))
   return self._data_channel_cache[url]
예제 #3
0
 def create_data_channel(self, remote_grpc_port):
     url = remote_grpc_port.api_service_descriptor.url
     if url not in self._data_channel_cache:
         logging.info('Creating channel for %s', url)
         grpc_channel = grpc.insecure_channel(
             url,
             # Options to have no limits (-1) on the size of the messages
             # received or sent over the data plane. The actual buffer size is
             # controlled in a layer above.
             options=[("grpc.max_receive_message_length", -1),
                      ("grpc.max_send_message_length", -1)])
         self._data_channel_cache[url] = GrpcClientDataChannel(
             beam_fn_api_pb2.BeamFnDataStub(grpc_channel))
     return self._data_channel_cache[url]
예제 #4
0
    def test_grpc_data_channel(self):
        data_channel_service = data_plane.GrpcServerDataChannel()

        server = grpc.server(futures.ThreadPoolExecutor(max_workers=2))
        beam_fn_api_pb2.add_BeamFnDataServicer_to_server(
            data_channel_service, server)
        test_port = server.add_insecure_port('[::]:0')
        server.start()

        data_channel_stub = beam_fn_api_pb2.BeamFnDataStub(
            grpc.insecure_channel('localhost:%s' % test_port))
        data_channel_client = data_plane.GrpcClientDataChannel(
            data_channel_stub)

        try:
            self._data_channel_test(data_channel_service, data_channel_client)
        finally:
            data_channel_client.close()
            data_channel_service.close()
            data_channel_client.wait()
            data_channel_service.wait()