Exemplo n.º 1
0
        protected override Server ConfigureServer()
        {
            var host = Config["Hosts:Local:Host"];
            var port = int.Parse(Config["Hosts:Local:Port"]);

            if (!_env.IsDevelopment())
            {
                port = Convert.ToInt32(Environment.GetEnvironmentVariable("EXCHANGE_SERVICE_HOST"));
            }

            var server = new Server
            {
                Services =
                {
                    ReviewService.BindService(
                        new ReviewServiceImpl(
                            _repositoryFactory,
                            _uow,
                            LoggerFactory
                            )),
                    Grpc.Health.V1.Health.BindService(new HealthImpl())
                },
                Ports = { new ServerPort(host, port, ServerCredentials.Insecure) }
            };

            Logger.LogInformation($"{nameof(ReviewService)} is listening on {host}:{port}.");
            return(server);
        }
Exemplo n.º 2
0
        protected override Server ConfigureServer()
        {
            GrpcEnvironment.SetLogger(new ConsoleLogger());

            var env         = _resolver.GetRequiredService <IHostingEnvironment>();
            var host        = Config["Hosts:Local:Host"];
            var port        = Config["Hosts:Local:Port"].ConvertTo <int>();
            var serviceName = Config["Hosts:ServiceName"];

            if (env.IsDevelopment())
            {
                IdentityModelEventSource.ShowPII = true;
            }

            if (!env.IsDevelopment())
            {
                port = Environment.GetEnvironmentVariable($"{serviceName.ToUpperInvariant()}_HOST").ConvertTo <int>();
            }

            _server = new Server
            {
                Services =
                {
                    ReviewService.BindService(new ReviewServiceImpl(_resolver)).Intercept(new AuthNInterceptor(_resolver)),
                    PingService.BindService(new PingServiceImpl(_resolver)).Intercept(new AuthNInterceptor(_resolver)),
                    Grpc.Health.V1.Health.BindService(new HealthImpl())
                },
                Ports = { new ServerPort(host, port, ServerCredentials.Insecure) }
            };

            Logger.LogInformation($"{nameof(ReviewService)} is listening on {host}:{port}.");
            return(_server);
        }