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);
- .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 200ns and with zero heap allocation.
When constructing a new result, there is total overhead of 400ns for one handler, and very low heap allocation.
When using async call model for getting a cached result is 450ns.
When using async call model for creating a new result with one handlers is 1350ns
|GetWithCache||228.7 ns||4.45 ns||6.67 ns||-||-|
|GetAsyncWithCache||397.1 ns||6.03 ns||5.64 ns||0.0286||240 B|
|GetWithoutCache||444.8 ns||8.84 ns||11.81 ns||0.0296||248 B|
|GetAsyncWithoutCache||1,362.1 ns||14.12 ns||16.81 ns||0.1125||943 B|
- Avalanche.Service.Abstractions - Interfaces and abstractions.
- Avalanche.Service - Service implementations.
- Avalanche.Service.DependencyInjection - Microsoft.Extensions.DependencyInjection support
- Avalanche.Utilities.Service - Utility handlers and requests.