public static async Task Main(string[] args) { //using (ILoggerFactory loggerFactory = new LoggerFactory().AddConsole()) using (ILoggerFactory loggerFactory = NullLoggerFactory.Instance) using (Tracer tracer = Tracing.Init("Client-app", loggerFactory)) { // You can use the OpenTracing.Mock.MockTracer in the unit test. // Register tracer globally. GlobalTracer.Register(tracer); IServiceCollection services = new ServiceCollection(); services .AddHelloClient() .AddSingleton <ITracer>(tracer); using (ServiceProvider serviceProvider = services.BuildServiceProvider()) { IHelloClient helloClient = serviceProvider.GetRequiredService <IHelloClient>(); using (IScope scope = tracer.BuildActiveSpan("Parallel-tasks")) { IEnumerable <Task> tasks = Enumerable.Range(1, 5).Select(n => helloClient.SayHello($"Balazs #{n}")); await Task.WhenAll(tasks); } } } }
public async Task <object> GetGeneratedClients([FromServices] IHelloClient helloClient) { try { return(await helloClient.GetMessageAsync()); } catch (ApiException e) { return(e.Content); } catch (Exception e) { Console.WriteLine(e); throw; } }
public ValuesController(IHelloClient client) { _client = client; }