Skip to content

Latest commit

 

History

History
62 lines (45 loc) · 2.57 KB

File metadata and controls

62 lines (45 loc) · 2.57 KB

Bet.Extensions.Hosting.Resilience

GitHub license Build status NuGet Nuget feedz.io

The second letter in the Hebrew alphabet is the ב bet/beit. Its meaning is "house". In the ancient pictographic Hebrew it was a symbol resembling a tent on a landscape.

Note: Pre-release packages are distributed via feedz.io.

Summary

This Library provides registration for hosting container of IHost interface for HttpClient message handlers.

buymeacoffee

Give a Star! ⭐

If you like or are using this project to learn or start your solution, please give it a star. Thanks!

Install

    dotnet add package Bet.Extensions.Hosting.Resilience

Usage

    public static IHostBuilder CreateHostBuilder(string[] args)
    {
        return Host.CreateDefaultBuilder(args)

                // adds resilience
                .UseResilienceOnStartup()

                // use correlationid for http context
                .UseCorrelationId(options => options.UseGuidForCorrelationId = true);
    }

    private async Task<string> GetWeatherForecast()
    {
        // inject IOptions<CorrelationIdOptions> correlationOptions
        // creates a parent activity context...
        var activity = new Activity("CallToBackend")
                            .AddBaggage(_correlationOptions.Header, Guid.NewGuid().ToString())
                            .Start();

        try
        {
            return await _httpClient.GetStringAsync(
                                   "http://localhost:5000/weatherforecastproxy");
        }
        finally
        {
            activity.Stop();
        }
    }