public void Init() { serviceImpl = new FakeTestService(); // Disable SO_REUSEPORT to prevent https://github.com/grpc/grpc/issues/10755 server = new Server(new[] { new ChannelOption(ChannelOptions.SoReuseport, 0) }) { Services = { TestService.BindService(serviceImpl) }, Ports = { { Host, ServerPort.PickUnused, TestCredentials.CreateSslServerCredentials() } } }; server.Start(); options = new List <ChannelOption> { new ChannelOption(ChannelOptions.SslTargetNameOverride, TestCredentials.DefaultHostOverride) }; }
/// <summary> /// Creates a started server runner. /// </summary> public static IServerRunner CreateStarted(ServerConfig config) { Grpc.Core.Utils.Preconditions.CheckArgument(config.ServerType == ServerType.ASYNC_SERVER); var credentials = config.SecurityParams != null?TestCredentials.CreateSslServerCredentials() : ServerCredentials.Insecure; // TODO: qps_driver needs to setup payload properly... int responseSize = config.PayloadConfig != null ? config.PayloadConfig.SimpleParams.RespSize : 0; var server = new Server { Services = { BenchmarkService.BindService(new BenchmarkServiceImpl(responseSize)) }, Ports = { new ServerPort(config.Host, config.Port, credentials) } }; server.Start(); return(new ServerRunnerImpl(server)); }
/// <summary> /// Creates a started server runner. /// </summary> public static IServerRunner CreateStarted(ServerConfig config) { Logger.Debug("ServerConfig: {0}", config); var credentials = config.SecurityParams != null?TestCredentials.CreateSslServerCredentials() : ServerCredentials.Insecure; if (config.AsyncServerThreads != 0) { Logger.Warning("ServerConfig.AsyncServerThreads is not supported for C#. Ignoring the value"); } if (config.CoreLimit != 0) { Logger.Warning("ServerConfig.CoreLimit is not supported for C#. Ignoring the value"); } if (config.CoreList.Count > 0) { Logger.Warning("ServerConfig.CoreList is not supported for C#. Ignoring the value"); } ServerServiceDefinition service = null; if (config.ServerType == ServerType.AsyncServer) { GrpcPreconditions.CheckArgument(config.PayloadConfig == null, "ServerConfig.PayloadConfig shouldn't be set for BenchmarkService based server."); service = BenchmarkService.BindService(new BenchmarkServiceImpl()); } else if (config.ServerType == ServerType.AsyncGenericServer) { var genericService = new GenericServiceImpl(config.PayloadConfig.BytebufParams.RespSize); service = GenericService.BindHandler(genericService.StreamingCall); } else { throw new ArgumentException("Unsupported ServerType"); } var channelOptions = new List <ChannelOption>(config.ChannelArgs.Select((arg) => arg.ToChannelOption())); var server = new Server(channelOptions) { Services = { service }, Ports = { new ServerPort("[::]", config.Port, credentials) } }; server.Start(); return(new ServerRunnerImpl(server)); }
public void Init() { server = new Server { Services = { TestService.BindService(new TestServiceImpl()) }, Ports = { { Host, ServerPort.PickUnused, TestCredentials.CreateSslServerCredentials() } } }; server.Start(); var options = new List <ChannelOption> { new ChannelOption(ChannelOptions.SslTargetNameOverride, TestCredentials.DefaultHostOverride) }; int port = server.Ports.Single().BoundPort; channel = new Channel(Host, port, TestCredentials.CreateSslCredentials(), options); client = TestService.NewClient(channel); }
public void Init() { // Disable SO_REUSEPORT to prevent https://github.com/grpc/grpc/issues/10755 server = new Server(new[] { new ChannelOption(ChannelOptions.SoReuseport, 0) }) { Services = { TestService.BindService(new TestServiceImpl()) }, Ports = { { Host, ServerPort.PickUnused, TestCredentials.CreateSslServerCredentials() } } }; server.Start(); var options = new List <ChannelOption> { new ChannelOption(ChannelOptions.SslTargetNameOverride, TestCredentials.DefaultHostOverride) }; int port = server.Ports.Single().BoundPort; channel = new Channel(Host, port, TestCredentials.CreateSslCredentials(), options); client = new TestService.TestServiceClient(channel); }
public void Init() { server = new Server { Services = { TestService.BindService(new FakeTestService()) }, Ports = { { Host, ServerPort.PickUnused, TestCredentials.CreateSslServerCredentials() } } }; server.Start(); options = new List <ChannelOption> { new ChannelOption(ChannelOptions.SslTargetNameOverride, TestCredentials.DefaultHostOverride) }; asyncAuthInterceptor = new AsyncAuthInterceptor(async(context, metadata) => { await Task.Delay(100).ConfigureAwait(false); // make sure the operation is asynchronous. metadata.Add("authorization", "SECRET_TOKEN"); }); }
public void Init() { // Disable SO_REUSEPORT to prevent https://github.com/grpc/grpc/issues/10755 server = new Server(new[] { new ChannelOption(ChannelOptions.SoReuseport, 0) }) { Services = { TestService.BindService(new FakeTestService()) }, Ports = { { Host, ServerPort.PickUnused, TestCredentials.CreateSslServerCredentials() } } }; server.Start(); options = new List <ChannelOption> { new ChannelOption(ChannelOptions.SslTargetNameOverride, TestCredentials.DefaultHostOverride) }; asyncAuthInterceptor = new AsyncAuthInterceptor(async(context, metadata) => { await Task.Delay(100).ConfigureAwait(false); // make sure the operation is asynchronous. metadata.Add("authorization", "SECRET_TOKEN"); }); }
private void Run() { var server = new Server { Services = { TestService.BindService(new TestServiceImpl()) } }; string host = "0.0.0.0"; int port = options.Port; if (options.UseTls.Value) { server.Ports.Add(host, port, TestCredentials.CreateSslServerCredentials()); } else { server.Ports.Add(host, options.Port, ServerCredentials.Insecure); } Console.WriteLine("Running server on " + string.Format("{0}:{1}", host, port)); server.Start(); server.ShutdownTask.Wait(); }
public void Init() { serviceMock = new Mock <TestService.ITestService>(); serviceMock.Setup(m => m.UnaryCall(It.IsAny <SimpleRequest>(), It.IsAny <ServerCallContext>())) .Returns(new Func <SimpleRequest, ServerCallContext, Task <SimpleResponse> >(UnaryCallHandler)); server = new Server { Services = { TestService.BindService(serviceMock.Object) }, Ports = { { Host, ServerPort.PickUnused, TestCredentials.CreateSslServerCredentials() } } }; server.Start(); options = new List <ChannelOption> { new ChannelOption(ChannelOptions.SslTargetNameOverride, TestCredentials.DefaultHostOverride) }; asyncAuthInterceptor = new AsyncAuthInterceptor(async(context, metadata) => { await Task.Delay(100).ConfigureAwait(false); // make sure the operation is asynchronous. metadata.Add("authorization", "SECRET_TOKEN"); }); }