Exemplo n.º 1
0
        public static IHostClient CreateHostClient(this GrpcClientFactory factory, string name)
        {
            var clientName = ClientName.Host(name);
            var client     = factory.CreateClient <Host.HostClient>(clientName);

            return(new HostClientWrapper(client));
        }
Exemplo n.º 2
0
        public static IFileSystemClient CreateFileSystemClient(this GrpcClientFactory factory, string name)
        {
            var clientName = ClientName.FileSystem(name);
            var client     = factory.CreateClient <FileSystem.FileSystemClient>(clientName);

            return(new FileSystemClientWrapper(client));
        }
        public async Task <IActionResult> GetAsync(CancellationToken cancellationToken)
        {
            var client = _grpcClientFactory.CreateClient <IGrpcService>(nameof(IGrpcService));

            var getServerProcessInfoResponse = await client.GetAsync(new GetServerProcessInfoRequest(), cancellationToken).ConfigureAwait(false);

            return(PartialView("_ServerProcessInfo", getServerProcessInfoResponse));
        }
        private async Task ReceiveRequestsAsync(CancellationToken cancellationToken)
        {
            try
            {
                _logger.LogInformation("Connecting to server to receive requests");

                var client = _grpcClientFactory.CreateClient <IGrpcService>(nameof(IGrpcService));

                _logger.LogInformation("Created client service");

                var requests = client.ReceiveRequestsAsync(cancellationToken);

                _logger.LogInformation("Connected to server! Listening for incoming requests...");

                await ProcessRequests(requests, cancellationToken).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                _logger.LogCritical(e, "Failed to connect to server to receive requests");
            }
        }
Exemplo n.º 5
0
        public CitiesClient(GrpcClientFactory grpcClientFactory)
        {
            var defaultMethodConfig = new MethodConfig
            {
                Names       = { MethodName.Default },
                RetryPolicy = new RetryPolicy
                {
                    MaxAttempts          = 5,
                    InitialBackoff       = TimeSpan.FromSeconds(1),
                    MaxBackoff           = TimeSpan.FromSeconds(5),
                    BackoffMultiplier    = 1.5,
                    RetryableStatusCodes = { StatusCode.Unavailable }
                }
            };

            _client = grpcClientFactory.CreateClient <Cities.CitiesClient>(nameof(Cities));
        }
Exemplo n.º 6
0
        //public DemoService(Greeter.GreeterClient client)
        //{
        //    //_client = client;
        //}

        public DemoService(GrpcClientFactory grpcClientFactory)
        {
            _client = grpcClientFactory.CreateClient <Greeter.GreeterClient>("Greeter");
        }
Exemplo n.º 7
0
 public ContactResolver(GrpcClientFactory clientFactory, ILoggerFactory loggerFactory)
 {
     _contactClient = clientFactory.CreateClient <ContactApiClient>(nameof(ContactApiClient));
     _logger        = loggerFactory.CreateLogger <ContactResolver>();
 }
Exemplo n.º 8
0
 public ContactService(GrpcClientFactory clientFactory, ILoggerFactory loggerFactory) : base()
 {
     _contactClient = clientFactory.CreateClient <ContactApiClient>(nameof(ContactApiClient));
     _logger        = loggerFactory.CreateLogger <ContactService>();
 }
Exemplo n.º 9
0
 public LeadService(GrpcClientFactory clientFactory, ILoggerFactory loggerFactory)
     : base()
 {
     _leadClient = clientFactory.CreateClient<LeadApi.Lead.LeadClient>(nameof(Lead.LeadClient));
     _logger = loggerFactory.CreateLogger<LeadService>();
 }