Avalanche service is a class library for processing requests and results, for mitigating consumers and producers.
There is separation of request, handling and result. This allows separation of aspect, inversion of control, expandability, plugin architecture, reusability, and decorability.
Service converts a request into a response by sending a query to be processed by a stack of handlers.
// Create handler Action<IQuery<string, Type>> handler = q => q.Response.SetValue( Type.GetType(q.Request) ); // Create service IService service = Services.Create(handler); // Create request string request = "System.String"; // Issue request Type? response = service.Get<string, Type>(request);
- Avalanche.Service.Abstractions - Interfaces and abstractions.
- Avalanche.Service - Service implementations.
- Avalanche.Service.DependencyInjection - Microsoft.Extensions.DependencyInjection support.
- Avalanche.Utilities.Service - Utility handlers and requests.
- .NET 6.0 and upwards.
- Zero heap allocation / very low heap allocation
- Very high performance
- Value-typed requests
- Strong generics on consumer API
- Strong gneerics on producer API
- Sync & async on consumer side
- Sync & async on producer side
- Scope hierarchies
- Recursive requests
- Cyclic requests
- Context requests
- Request specific cancel tokens
- Service life-time specific cancel tokens
- Complete dispose/ownership management of services and cached values
- Error management within and outside process
- Dependency-injection supported
- Logging supported
- Cache lines can be disconnected
When getting a result that is already in cache, the result is provided at 277ns and with zero heap allocation.
When constructing a new result, there is total overhead of 700ns for about 10 handlers, and very log heap allocation.
When using async call model for creating a new result for about 10 handlers, there is 4,106ns overhead.
When using async call model for getting a cached result, the result is provided at 490ns.
|Method||Mean||Error||StdDev||Gen 0||Gen 1||Allocated|
|GetWithCache||277.5 ns||4.03 ns||3.57 ns||-||-||-|
|GetWithoutCache||700.1 ns||12.46 ns||11.65 ns||0.0381||-||320 B|
|GetAsyncWithCache||490.1 ns||4.26 ns||3.99 ns||0.0324||-||272 B|
|GetAsyncWithoutCache||4,106.3 ns||67.99 ns||63.59 ns||0.2060||-||1720 B|