public RpcServicePublisher(RpcConnectionInfo connectionInfo, IRpcServiceDefinitionsProvider serviceDefinitionsProvider) { this.InitConnectionInfo(connectionInfo); this.DefinitionsProvider = serviceDefinitionsProvider ?? throw new ArgumentNullException(nameof(serviceDefinitionsProvider)); }
public static TService GetServiceSingleton <TService>(this IRpcConnectionManager connectionManager, RpcConnectionInfo connectionInfo, bool useSyncContext = true) where TService : class { if (connectionManager == null) { throw new ArgumentNullException(nameof(connectionManager)); } return(connectionManager.GetServiceSingleton <TService>(connectionInfo, useSyncContext ? SynchronizationContext.Current : null)); }
public bool CanCreateChannel(RpcConnectionInfo connectionInfo) { return(connectionInfo?.HostUrl?.Scheme == WellKnownRpcSchemes.Grpc); }
public bool CanCreateChannel(RpcConnectionInfo connectionInfo) { return(connectionInfo?.HostUrl?.Scheme == GrpcScheme); }
internal NetGrpcConnection( RpcConnectionInfo connectionInfo, IRpcClientOptions?options, GrpcProxyGenerator proxyGenerator, GrpcNet.Client.GrpcChannelOptions?channelOptions) : base(connectionInfo, options, proxyGenerator) { if (connectionInfo is null) { throw new ArgumentNullException(nameof(connectionInfo)); } var scheme = connectionInfo.HostUrl?.Scheme; if (connectionInfo.HostUrl != null && (scheme == WellKnownRpcSchemes.Grpc || scheme == "https" || scheme == "http")) { GrpcNet.Client.GrpcChannelOptions actualChannelOptions = ExtractOptions(options, channelOptions); this.isSecure = scheme == "https" || scheme == WellKnownRpcSchemes.Grpc; var interceptors = options?.Interceptors ?? ImmutableList <RpcClientCallInterceptor> .Empty; int nInterceptors = interceptors.Count; if (nInterceptors > 0) { GrpcCore.CallCredentials callCredentials; if (nInterceptors > 1) { GrpcCore.CallCredentials[] allCallCredentials = new GrpcCore.CallCredentials[nInterceptors]; for (int index = 0; index < nInterceptors; index++) { var callInterceptor = interceptors[index]; allCallCredentials[index] = GrpcCore.CallCredentials.FromInterceptor((context, metadata) => callInterceptor(new GrpcCallMetadata(metadata))); } callCredentials = GrpcCore.CallCredentials.Compose(allCallCredentials); } else { var callInterceptor = interceptors[0]; callCredentials = GrpcCore.CallCredentials.FromInterceptor((context, metadata) => callInterceptor(new GrpcCallMetadata(metadata))); } var channelCredentials = actualChannelOptions.Credentials; if (channelCredentials == null) { if (this.isSecure) { channelCredentials = new GrpcCore.SslCredentials(); } else { channelCredentials = GrpcCore.ChannelCredentials.Insecure; } } actualChannelOptions.Credentials = GrpcCore.ChannelCredentials.Create(channelCredentials, callCredentials); } var channelUri = scheme == WellKnownRpcSchemes.Grpc ? new Uri($"https://{connectionInfo.HostUrl.Authority}/") : connectionInfo.HostUrl; this.Channel = GrpcNet.Client.GrpcChannel.ForAddress(channelUri, actualChannelOptions); this.CallInvoker = this.Channel.CreateCallInvoker(); } else { throw new NotImplementedException($"NetGrpcConnection is only implemented for the '{WellKnownRpcSchemes.Grpc}' scheme."); } }
public LightweightDiscoveryEndPoint(RpcConnectionInfo connectionInfo, ILogger?logger = null) { this.connectionInfo = connectionInfo; this.logger = logger; }
public bool CanCreateChannel(RpcConnectionInfo connectionInfo) { return(connectionInfo?.HostUrl?.Scheme is string scheme && (scheme == WellKnownRpcSchemes.LightweightTcp || scheme == WellKnownRpcSchemes.LightweightPipe)); }