/// <summary> /// ServerBuilder /// </summary> /// <param name="serviceProvider"></param> /// <param name="grpcServerOptions"></param> /// <param name="serverInterceptors"></param> /// <param name="grpcServices"></param> /// <param name="loggerFactory"></param> public ServerBuilder(IServiceProvider serviceProvider, IOptions <GrpcServerOptions> grpcServerOptions, IEnumerable <ServerInterceptor> serverInterceptors, IEnumerable <IGrpcService> grpcServices, ILoggerFactory loggerFactory) { ServiceProviderAccessor.SetServiceProvider(serviceProvider); this._grpcServices.AddRange(grpcServices); this._grpcServerOptions = grpcServerOptions.Value; this._serverInterceptors = serverInterceptors; this._loggerFactory = loggerFactory; }
public static Server UseGrpcOptions(this Server server, GrpcServerOptions options) { GrpcServerOptions.Instance.ServiceAddress = options.ServiceAddress; GrpcServerOptions.Instance.ConsulUrl = options.ConsulUrl; GrpcServerOptions.Instance.ConsulServiceName = options.ConsulServiceName; GrpcServerOptions.Instance.ConsulTags = options.ConsulTags; //添加服务IPAndPort var ipPort = NetHelper.GetIPAndPort(GrpcServerOptions.Instance.ServiceAddress); server.Ports.Add(new ServerPort(ipPort.Item1, ipPort.Item2, ServerCredentials.Insecure)); return(server); }
/// <summary> /// ServerBuilder /// </summary> /// <param name="serviceProvider"></param> /// <param name="grpcServerOptions"></param> /// <param name="serverInterceptors"></param> /// <param name="grpcServices"></param> /// <param name="loggerFactory"></param> public ServerBuilder(IServiceProvider serviceProvider, IOptions <GrpcServerOptions> grpcServerOptions, IEnumerable <ServerInterceptor> serverInterceptors, IEnumerable <IGrpcService> grpcServices, ILoggerFactory loggerFactory) { ServiceProviderAccessor.SetServiceProvider(serviceProvider); this._grpcServices.AddRange(grpcServices); this._grpcServerOptions = grpcServerOptions.Value; this._loggerFactory = loggerFactory; //初始化配制,注入中间件,GrpcService this.InitGrpcOptions() //初始化配制 .UseInterceptor(serverInterceptors) //注入中间件 .UseLoggerFactory() //使用LoggerFactory .UseJaeger(); }