public async Task Run(CancellationToken token) { _logger.LogInformation("Starting Service ..."); _consumer.Start <HelloRequest>("topic://test/*", "micro:samplebackground:samplequeue", MessageReceived); try { while (!token.IsCancellationRequested) { var helloInfo = await _serviceDiscovery.Discover("helloworld"); if (!string.IsNullOrEmpty(helloInfo.host) && helloInfo.port > 0) { var channelTarget = $"{helloInfo.host}:{helloInfo.port}"; var channel = new Channel(channelTarget, ChannelCredentials.Insecure); var client = new Hello.HelloClient(channel); var rr = await client.SayHelloAsync(new HelloRequest { Name = "Vincent" }); _publisher.Send("topic://test/test", new Message <HelloRequest>(new HelloRequest { Name = rr.Message })); } _logger.LogInformation("Will wait for 5 seconds"); await Task.Delay(TimeSpan.FromMilliseconds(5000), token); } } catch (TaskCanceledException) { _logger.LogInformation("Background Process cancelled"); } finally { _logger.LogInformation("Stopping consumer"); _consumer.Stop(); } _logger.LogInformation("Background Process stopped"); }
public BaseLambdaRequestProcessor(IServiceDiscovery serviceDiscovery) { _scopeFactory = serviceDiscovery.Discover().GetRequiredService <IServiceScopeFactory>(); }
public HttpCommandInvoker(IHttpClient httpClient, IServiceDiscovery discoSrv) { this._httpClient = httpClient; this._url = discoSrv.Discover(typeof(TCommand)); }
public IEnumerable <ServiceActor> Retrieve(Type serviceType) { return(_discovery.Discover(serviceType)); }