TheOmenDen.Shared.Services
1.7.27.28
Prefix Reserved
dotnet add package TheOmenDen.Shared.Services --version 1.7.27.28
NuGet\Install-Package TheOmenDen.Shared.Services -Version 1.7.27.28
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TheOmenDen.Shared.Services" Version="1.7.27.28" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TheOmenDen.Shared.Services --version 1.7.27.28
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TheOmenDen.Shared.Services, 1.7.27.28"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TheOmenDen.Shared.Services as a Cake Addin #addin nuget:?package=TheOmenDen.Shared.Services&version=1.7.27.28 // Install TheOmenDen.Shared.Services as a Cake Tool #tool nuget:?package=TheOmenDen.Shared.Services&version=1.7.27.28
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
The Omen Den Shared Services
This library contains some simple implementations of the services defined in the Interface library
- The Omen Den Shared Interface Library
- Note: These libraries have dependencies on The Omen Den Shared Library
The goal with this library is to provide simple abstract services for calling external APIs and provide Scrutor
based registration for any sub-services that inherit from them.
Of course, while we have the implementations defined in this library, we also have the dependency injection defined. The way it should work is by inheriting from either the ApiServiceBase
or the ApiStreamServiceBase
abstract classes, and then calling the IserviceCollection
extension AddTheOmenDenHttpServices
to allow scrutor
to register them into the dependency injection container.
- This was done in an attempt to streamline and smooth out my poor memory when it comes to registering services.
- Note the use of
Polly
in this library to define automatic retry policies forHttpClients
. - We also have a class - HttpClientConfiguration for your convinience when it comes to registering named clients via appsettings, or some other form of
Action
"passing"
As usual, here are the rationales for the services
1. ApiServiceBase<T>
- Provides CRUD functionality based off of HTTP Methods
- Allows for injection of a named
IHttpClientFactory
and implements theIOptions<T>
pattern. - The idea here is with the
IHttpClientFactory
, using a "fresh"HttpClient
per request thus saving on costs, and allowing for better life cycle management. - All methods return a
Task<ApiResponse<TResponse>>
of some sort, the reasoning for this is two fold- To allow for better handling when a request fails to process for any reason
- To allow for better tracability and response deserialization.
- There are two methods for stream deserialization to help smooth out issues with response contents, and to allow the deserialization into a string for error handling.
2. ApiStreamServiceBase<T>
- Provides ReadOnly streaming functionality from an external API
- As with the previous implementation we return resposnes based off of the
ApiResponse
object. - This decision is made more evident when we call
StreamApiResultsAsync
since we can now handle each request failure within anawait foreach
loop on the consumer side. - The main justification for this approach is for extensibility and better error reporting.
- We do our best to maintain our available resources by limiting the exceptions thrown, preferring to capture them, and returning objects that function similarly.
- As with the previous implementation these methods are all defined as
virtual
, allowing for you to override them on a case by case basis.
#ToDos
- Allow better Dependency injection
- Add support for various Injection frameworks such as AutoFac and SimpleInjector
- Better memory usage
- As with everything, we try to optimize what we do as much as possible - here we just need to make sure the resources we use are properly disposed.
- Provide source generators and Json generators for the responses that we deserialize.
- This will allow us to autogenerate services that are efficient and can be automatically registered from user supplied code.
- On the JSON side of things, this will allow for more efficient serialization and deserialization of requests and responses.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.AspNetCore.Http.Extensions (>= 2.2.0)
- Microsoft.Extensions.Http (>= 6.0.0)
- Microsoft.Extensions.Http.Polly (>= 6.0.7)
- Scrutor.AspNetCore (>= 3.3.0)
- System.Interactive.Async (>= 6.0.1)
- System.Net.Http (>= 4.3.4)
- TheOmenDen.Shared (>= 2022.7.26.331)
- TheOmenDen.Shared.Interfaces (>= 1.7.26.1301)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.7.27.28 | 2,074 | 7/27/2022 |
Split off from the main TheOmenDen.Shared package