public static void Main() { EnsureLoadAssembly.Load(); var channelOptions = new GrpcChannelOptions() { LoggerFactory = GetConsoleLoggerFactory(), HttpClient = CreateGrpcHttpClient(acceptSelfSignedCertificate: true), }; var channelTarget = Environment.GetEnvironmentVariable("SERVICE_TARGET"); var channel = GrpcChannel.ForAddress(channelTarget, channelOptions); var client = new Greeter.GreeterClient(channel); var user = "******"; for (int i = 0; i < 10000; i++) { try { var reply = client.SayHello(new HelloRequest { Name = user }); Console.WriteLine("Greeting: " + reply.Message); } catch (RpcException e) { Console.WriteLine("Error invoking: " + e.Status); } Thread.Sleep(1000); } channel.ShutdownAsync().Wait(); Console.WriteLine(); }
public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddGrpcClient <Greeter.GreeterClient>(o => { EnsureLoadAssembly.Load(); var target = Configuration["SERVICE_TARGET"]; o.Address = new UriBuilder(target).Uri; o.ChannelOptionsActions.Add((options) => { options.Attributes = GetAttributes(); }); }); }