public ConferencesServiceClientGrpc(IConfiguration config, GrpcChannel channel, CallInvoker invoker) { _config = config; _baseUrl = _config[Configuration.BackendUrlKey]; //_client = new Conference.Conferences.ConferencesClient(channel); _client = channel.CreateGrpcService <IConferencesService>(); //_client = invoker.CreateGrpcService<IConferencesService>(); }
public ProtobufGrpcClientCallTest(SomeObject payload) { _payload = payload; _httpHandler = new StubHttpMessageHandler(ProtobufMarshallerFactory.Default, _payload); _channel = GrpcChannel.ForAddress("http://localhost", new GrpcChannelOptions { HttpHandler = _httpHandler }); _proxy = _channel.CreateGrpcService <ITestService>(); }
public ProtobufGrpcCombinedCallTest(SomeObject payload) { _payload = payload; _server = new TestServer(new WebHostBuilder().UseStartup <Startup>()); _client = _server.CreateClient(); _channel = GrpcChannel.ForAddress("http://localhost", new GrpcChannelOptions { HttpClient = _client }); _proxy = _channel.CreateGrpcService <ITestService>(); }
private static void ConfigureGrpc(IServiceCollection aServiceCollection) { aServiceCollection.AddSingleton ( aServiceProvider => { // Get the service address from appsettings.json IConfiguration config = aServiceProvider.GetRequiredService <IConfiguration>(); string backendUrl = config["BackendUrl"]; // If no address is set then fallback to the current webpage URL if (string.IsNullOrEmpty(backendUrl)) { //NavigationManager navigationManager = aServiceProvider.GetRequiredService<NavigationManager>(); backendUrl = "https://localhost:5001"; } Console.WriteLine($"backendUrl:{backendUrl}"); // Create a channel with a GrpcWebHandler that is addressed to the backend server. // // GrpcWebText is used because server streaming requires it. If server streaming is not used in your app // then GrpcWeb is recommended because it produces smaller messages. var httpHandler = new GrpcWebHandler(GrpcWebMode.GrpcWeb, new HttpClientHandler()); return(GrpcChannel.ForAddress ( backendUrl, new GrpcChannelOptions { HttpHandler = httpHandler, //CompressionProviders = ..., //Credentials = ..., //DisposeHttpClient = ..., //HttpClient = ..., //LoggerFactory = ..., //MaxReceiveMessageSize = ..., //MaxSendMessageSize = ..., //ThrowOperationCanceledOnCancellation = ..., } )); } ); aServiceCollection.AddSingleton <ISuperheroService> ( aServiceProvider => { GrpcChannel grpcChannel = aServiceProvider.GetRequiredService <GrpcChannel>(); return(grpcChannel.CreateGrpcService <ISuperheroService>()); } ); }
public ConferencesServiceClientGrpc(IConfiguration config, GrpcChannel channel, CallInvoker invoker, IHttpClientFactory httpClientFactory) { _config = config; _baseUrl = _config["BackendUrl"]; _statisticsUrl = new Uri(new Uri(_baseUrl), "api/statistics/").ToString(); _anonHttpClient = httpClientFactory.CreateClient("ConfTool.ServerAPI.Anon"); //_client = new Conference.Conferences.ConferencesClient(channel); _client = channel.CreateGrpcService <IConferencesService>(); //_client = GrpcClientFactory.CreateGrpcService<IConferencesService>(invoker); }
public XRpcClient(XRpcClientOptions options) { if (!Uri.IsWellFormedUriString(options.Url, UriKind.Absolute)) { throw new Exception($"XRpc invalid URI"); } Options = options; channel = GrpcChannel.ForAddress(options.Url); var service = channel.CreateGrpcService <IDalService>(); //todo }
public T GetClient <T>() where T : class { var isAutogenerated = typeof(T).IsSubclassOf(typeof(Grpc.Core.ClientBase)); if (isAutogenerated) { return((T)Activator.CreateInstance(typeof(T), _channel)); } var svc = _channel.CreateGrpcService <T>(); return(svc); }
/// <summary> /// Constructor. /// </summary> /// <param name="isAdminOverride"> /// Optionally overrides detection of elevated permissions enabled for the /// current process. This is used for testing. /// </param> /// <param name="socketPath"> /// Optionally overrides the default desktop service unix socket path. This /// is used for testing purposes. /// </param> public HyperVProxy(bool?isAdminOverride = null, string socketPath = null) { if (isAdminOverride.HasValue) { isAdmin = isAdminOverride.Value; } else { isAdmin = NeonHelper.HasElevatedPermissions; } if (isAdmin) { hypervClient = new HyperVClient(); } else { grpcChannel = NeonGrpcServices.CreateDesktopServiceChannel(socketPath); desktopService = grpcChannel.CreateGrpcService <IGrpcDesktopService>(); } }
public GrpcLinqServiceClient(GrpcChannel channel) { _channel = channel; _client = channel.CreateGrpcService <IGrpcLinqService>(); }
public CodeFirstGrpcClient(string apiUrl) { _channel = GrpcChannel.ForAddress(apiUrl); _bookService = _channel.CreateGrpcService <IBookService>(); }
/// <summary> /// 获取服务 /// </summary> /// <typeparam name="TService"></typeparam> /// <returns></returns> public TService GetService <TService>() where TService : class { return(_grpcChannel.CreateGrpcService <TService>()); }
public MandoServiceGrpcClient(GrpcChannel channel) { _mandoService = channel.CreateGrpcService <IMandoService>(); }
public ConferencesService(IConfiguration config, GrpcChannel channel) { _config = config; _baseUrl = _config["BackendUrl"]; _client = channel.CreateGrpcService <IConferencesService>(); }
public object Invoke(Func <TContract, object> func) { var instance = _client.CreateGrpcService <TContract>(); return(func(instance)); }
public ConferenceServiceGrpcClient(GrpcChannel channel) { _serviceClient = channel.CreateGrpcService <IConferenceService>(); }