Exemplo n.º 1
0
 public GrpcServer(FunctionRpc.FunctionRpcBase serviceImpl)
 {
     _server = new Server
     {
         Services = { FunctionRpc.BindService(serviceImpl) },
         Ports    = { new ServerPort("127.0.0.1", ServerPort.PickUnused, ServerCredentials.Insecure) }
     };
 }
Exemplo n.º 2
0
        public AspNetCoreGrpcServer(FunctionRpc.FunctionRpcBase service, IScriptEventManager scriptEventManager, ILogger <AspNetCoreGrpcServer> logger)
        {
            int port = WorkerUtilities.GetUnusedTcpPort();

            _grpcHostBuilder = AspNetCoreGrpcHostBuilder.CreateHostBuilder(service, scriptEventManager, port);
            _logger          = logger;
            Uri = new Uri($"http://{WorkerConstants.HostName}:{port}");
        }
Exemplo n.º 3
0
        public GrpcServer(FunctionRpc.FunctionRpcBase serviceImpl)
        {
            ChannelOption maxReceiveMessageLength = new ChannelOption(ChannelOptions.MaxReceiveMessageLength, MaxMessageLengthBytes);
            ChannelOption maxSendMessageLength    = new ChannelOption(ChannelOptions.MaxSendMessageLength, MaxMessageLengthBytes);

            ChannelOption[] grpcChannelOptions = { maxReceiveMessageLength, maxSendMessageLength };
            _server = new Server(grpcChannelOptions)
            {
                Services = { FunctionRpc.BindService(serviceImpl) },
                Ports    = { new ServerPort("127.0.0.1", ServerPort.PickUnused, ServerCredentials.Insecure) }
            };
        }
Exemplo n.º 4
0
        public static IHostBuilder CreateHostBuilder(FunctionRpc.FunctionRpcBase service, IScriptEventManager scriptEventManager, int port) =>
        new HostBuilder().ConfigureWebHost(webBuilder =>
        {
            webBuilder.UseKestrel(options =>
            {
                options.Listen(IPAddress.Parse(WorkerConstants.HostName), port, listenOptions =>
                {
                    listenOptions.Protocols = HttpProtocols.Http2;
                });
            });

            webBuilder.ConfigureServices(services =>
            {
                services.AddSingleton(scriptEventManager);
                services.AddSingleton(service);
            });

            webBuilder.UseStartup <Startup>();
        });