Пример #1
0
 private async Task CompleteServiceAsync(string serviceName, QueryResult <CatalogService[]> result)
 {
     await Task.WhenAll(
         _consulStateObservations.WaitForAddAsync(),
         _consulClient.CompleteServiceAsync(serviceName, result)
         );
 }
Пример #2
0
        public async Task OkServiceResponseIsStreamed()
        {
            List <ServiceObservation> observations = new List <ServiceObservation>();

            _observableConsul.ObserveService("MyService").Subscribe(o => {
                observations.Add(o);
            });
            await _consulClient.CompleteServiceAsync("MyService", new QueryResult <CatalogService[]>
            {
                StatusCode = HttpStatusCode.OK,
                Response   = new CatalogService[] {
                    new CatalogService {
                        ServiceName    = "MyService",
                        ServiceAddress = "10.8.8.3"
                    }
                }
            });

            observations.Should().HaveCount(1);
            observations[0].ServiceName.Should().Be("MyService");
            observations[0].Result.Response[0].ServiceAddress.Should().Be("10.8.8.3");
        }