![]() |
VOOZH | about |
dotnet add package Apizr.Extensions.Microsoft.DependencyInjection --version 6.4.2
NuGet\Install-Package Apizr.Extensions.Microsoft.DependencyInjection -Version 6.4.2
<PackageReference Include="Apizr.Extensions.Microsoft.DependencyInjection" Version="6.4.2" />
<PackageVersion Include="Apizr.Extensions.Microsoft.DependencyInjection" Version="6.4.2" />Directory.Packages.props
<PackageReference Include="Apizr.Extensions.Microsoft.DependencyInjection" />Project file
paket add Apizr.Extensions.Microsoft.DependencyInjection --version 6.4.2
#r "nuget: Apizr.Extensions.Microsoft.DependencyInjection, 6.4.2"
#:package Apizr.Extensions.Microsoft.DependencyInjection@6.4.2
#addin nuget:?package=Apizr.Extensions.Microsoft.DependencyInjection&version=6.4.2Install as a Cake Addin
#tool nuget:?package=Apizr.Extensions.Microsoft.DependencyInjection&version=6.4.2Install as a Cake Tool
Refit based web api client, but resilient (retry, connectivity, cache, auth, log, priority...)
π Read - Documentation
π Browse - Source
π Watch - Tutorials
The Apizr project was motivated by this 2015 famous blog post about resilient networking.
Its main focus was to address at least everything explained into this article, meanning:
But also, some more core features like:
And more integration/extension independent optional features like:
The list is not exhaustive, thereβs more, but what we wanted was playing with all of it with as less code as we could, not worrying about plumbing things and being sure everything is wired and handled by design or almost.
Inspired by Refit.Insane.PowerPack, we wanted to make it simple to use, mixing attribute decorations and fluent configuration.
An api definition with some attributes:
// (Polly) Define a resilience pipeline key
// OR use Microsoft Resilience instead
[assembly:ResiliencePipeline("TransientHttpError")]
namespace Apizr.Sample
{
// (Apizr) Define your web api base url and ask for cache and logs
[BaseAddress("https://reqres.in/"),
Cache(CacheMode.FetchOrGet, "01:00:00"),
Log(HttpMessageParts.AllButBodies)]
public interface IReqResService
{
// (Refit) Define your web api interface methods
[Get("/api/users")]
Task<UserList> GetUsersAsync([RequestOptions] IApizrRequestOptions options);
[Get("/api/users/{userId}")]
Task<UserDetails> GetUserAsync([CacheKey] int userId, [RequestOptions] IApizrRequestOptions options);
[Post("/api/users")]
Task<User> CreateUser(User user, [RequestOptions] IApizrRequestOptions options);
}
}
Some resilience strategies:
// (Polly) Create a resilience pipeline (if not using Microsoft Resilience)
var resiliencePipelineBuilder = new ResiliencePipelineBuilder<HttpResponseMessage>()
.AddRetry(
new RetryStrategyOptions<HttpResponseMessage>
{
ShouldHandle = new PredicateBuilder<HttpResponseMessage>()
.Handle<HttpRequestException>()
.HandleResult(response =>
response.StatusCode is >= HttpStatusCode.InternalServerError
or HttpStatusCode.RequestTimeout),
Delay = TimeSpan.FromSeconds(1),
MaxRetryAttempts = 3,
UseJitter = true,
BackoffType = DelayBackoffType.Exponential
});
An instance of this managed api:
Relies on IServiceCollection extension methods approach.
// (Logger) Configure logging the way you want, like
services.AddLogging(loggingBuilder => loggingBuilder.AddDebug());
// (Apizr) Add an Apizr manager for the defined api to your container
services.AddApizrManagerFor<IReqResService>(
options => options
// With a cache handler
.WithAkavacheCacheHandler()
// If using Microsoft Resilience
.ConfigureHttpClientBuilder(builder => builder
.AddStandardResilienceHandler()));
// (Polly) Add the resilience pipeline (if not using Microsoft Resilience)
services.AddResiliencePipeline<string, HttpResponseMessage>("TransientHttpError",
builder => builder.AddPipeline(resiliencePipelineBuilder.Build()));
...
// (Apizr) Get your manager instance the way you want, like
var reqResManager = serviceProvider.GetRequiredService<IApizrManager<IReqResService>>();
Relies on static builder instantiation approach.
// (Polly) Add the resilience pipeline with its key to a registry
var resiliencePipelineRegistry = new ResiliencePipelineRegistry<string>();
resiliencePipelineRegistry.TryAddBuilder<HttpResponseMessage>("TransientHttpError",
(builder, _) => builder.AddPipeline(resiliencePipelineBuilder.Build()));
// (Apizr) Get your manager instance
var reqResManager = ApizrBuilder.Current.CreateManagerFor<IReqResService>(
options => options
// With a logger
.WithLoggerFactory(LoggerFactory.Create(loggingBuilder =>
loggingBuilder.Debug()))
// With the defined resilience pipeline registry
.WithResiliencePipelineRegistry(resiliencePipelineRegistry)
// And with a cache handler
.WithAkavacheCacheHandler());
And then you're good to go:
var userList = await reqResManager.ExecuteAsync((api, opt) => api.GetUsersAsync(opt));
This request will be managed with the defined resilience strategies, data cached and all logged.
Apizr has a lot more to offer, just read the doc!
| Project | Current | Upcoming |
|---|---|---|
| Apizr | π NuGet |
π NuGet Pre Release |
| Apizr.Extensions.Microsoft.DependencyInjection | π NuGet |
π NuGet Pre Release |
| Project | Current | Upcoming |
|---|---|---|
| Apizr.Extensions.Microsoft.Caching | π NuGet |
π NuGet Pre Release |
| Apizr.Integrations.Akavache | π NuGet |
π NuGet Pre Release |
| Apizr.Integrations.MonkeyCache | π NuGet |
π NuGet Pre Release |
| Project | Current | Upcoming |
|---|---|---|
| Apizr.Integrations.Fusillade | π NuGet |
π NuGet Pre Release |
| Apizr.Integrations.MediatR | π NuGet |
π NuGet Pre Release |
| Apizr.Integrations.Optional | π NuGet |
π NuGet Pre Release |
| Project | Current | Upcoming |
|---|---|---|
| Apizr.Integrations.AutoMapper | π NuGet |
π NuGet Pre Release |
| Apizr.Integrations.Mapster | π NuGet |
π NuGet Pre Release |
| Project | Current | Upcoming |
|---|---|---|
| Apizr.Integrations.FileTransfer | π NuGet |
π NuGet Pre Release |
| Apizr.Extensions.Microsoft.FileTransfer | π NuGet |
π NuGet Pre Release |
| Apizr.Integrations.FileTransfer.MediatR | π NuGet |
π NuGet Pre Release |
| Apizr.Integrations.FileTransfer.Optional | π NuGet |
π NuGet Pre Release |
| Project | Current | Upcoming |
|---|---|---|
| Refitter | π NuGet |
π NuGet Pre Release |
| Refitter.SourceGenerator | π NuGet |
π NuGet Pre Release |
Install the NuGet reference package of your choice:
Choose which generating approach suites to your needs by installing either:
Apizr core package make use of well known nuget packages to make the magic appear:
| Package | Features |
|---|---|
| Refit | Auto-implement web api interface and deal with HttpClient |
| Polly.Extensions | Apply some policies like Retry, CircuitBreaker, etc... |
| Microsoft.Extensions.Logging.Abstractions | Delegate logging layer to MS Extensions Logging |
It also comes with some handling interfaces to let you provide your own services for:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 3 NuGet packages that depend on Apizr.Extensions.Microsoft.DependencyInjection:
| Package | Downloads |
|---|---|
|
Apizr.Integrations.MediatR
Refit based web api client management, but resilient (retry, connectivity, cache, auth, log, priority...) |
|
|
Apizr.Extensions.Microsoft.Caching
Refit based web api client management, but resilient (retry, connectivity, cache, auth, log, priority...) |
|
|
Apizr.Extensions.Microsoft.FileTransfer
Refit based web api client management, but resilient (retry, connectivity, cache, auth, log, priority...) |
Showing the top 1 popular GitHub repositories that depend on Apizr.Extensions.Microsoft.DependencyInjection:
| Repository | Stars |
|---|---|
|
LykosAI/StabilityMatrix
Multi-Platform Package Manager for Stable Diffusion
|
| Version | Downloads | Last Updated |
|---|---|---|
| 6.4.2 | 15,138 | 2/20/2025 |
| 6.4.1 | 1,866 | 12/18/2024 |
| 6.4.0 | 4,761 | 11/22/2024 |
| 6.4.0-preview.4 | 156 | 11/19/2024 |
| 6.4.0-preview.3 | 152 | 11/14/2024 |
| 6.4.0-preview.2 | 257 | 11/6/2024 |
| 6.4.0-preview.1 | 159 | 10/25/2024 |
| 6.3.0 | 13,930 | 10/17/2024 |
| 6.2.0 | 571 | 10/11/2024 |
| 6.1.0 | 753 | 10/1/2024 |
| 6.0.0 | 907 | 9/10/2024 |
| 6.0.0-preview.9 | 172 | 8/29/2024 |
| 6.0.0-preview.8 | 151 | 8/3/2024 |
| 6.0.0-preview.7 | 863 | 7/25/2024 |
| 6.0.0-preview.6 | 182 | 7/18/2024 |
| 6.0.0-preview.5 | 194 | 6/24/2024 |
| 6.0.0-preview.4 | 209 | 5/24/2024 |
| 6.0.0-preview.3 | 2,783 | 5/2/2024 |
| 6.0.0-preview.2 | 364 | 3/29/2024 |
| 6.0.0-preview.1 | 169 | 3/8/2024 |