Esempio n. 1
0
        public static IServiceCollection AddAccountsService(this IServiceCollection services)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            services.AddSingleton <IAccountsService>(serviceProvider =>
            {
                var tracer             = serviceProvider.GetRequiredService <ITracer>();
                var tracingInterceptor = new ClientTracingInterceptor
                                         .Builder(tracer)
                                         .WithStreaming()
                                         .WithVerbosity()
                                         .Build();

                var channel = new Channel("localhost:4999", ChannelCredentials.Insecure);
                var invoker = channel.Intercept(tracingInterceptor);
                var client  = new Accounts.AccountsClient(invoker);

                return(new AccountsGrpcClient(client));
            });

            return(services);
        }
 public AccountsGrpcClient(Accounts.AccountsClient client)
 {
     this._client = client;
 }