Microservice for categories.
Defines categories.
Uses CQRS to fetch entities from data-source without defining any.
Provides gRPC services for integrations into other services.
Branch | CI |
---|---|
master | |
develop |
Protobuf service definitions located at SorenA/lightops-commerce-proto.
Category is implemented in Domain.GrpcServices.CategoryGrpcService
.
Health is implemented in Domain.GrpcServices.HealthGrpcService
.
Health-checks conforms to the GRPC Health Checking Protocol
Available services are as follows
service = '' - System as a whole
service = 'lightops.service.CategoryService' - Category
For embedding a gRPC client for use with Kubernetes, see grpc-ecosystem/grpc-health-probe
A sample application hosting the gRPC service with mock data is available in the samples/Sample.CategoryService
project.
LightOps packages available on NuGet:
LightOps.DependencyInjection
LightOps.CQRS
Register during startup through the AddCategoryService(options)
extension on IDependencyInjectionRootComponent
.
services.AddLightOpsDependencyInjection(root =>
{
root
.AddCqrs()
.AddCategoryService(service =>
{
// Configure service
// ...
});
});
services.AddGrpc();
Register gRPC services for integrations.
app.UseEndpoints(endpoints =>
{
endpoints.MapGrpcService<CategoryGrpcService>();
endpoints.MapGrpcService<HealthGrpcService>();
// Map other endpoints...
});
The gRPC services use ICommandDispatcher
& IQueryDispatcher
from the LightOps.CQRS
package to dispatch commands and queries, see configuration bellow.
A component backend is required, implementing the command & query handlers tied to a data-source, see configuration overridables bellow.
A custom backend, or one of the following standard backends can be used:
- InMemory
Using the ICategoryServiceComponent
configuration, the following can be overridden:
public interface ICategoryServiceComponent
{
#region Query Handlers
ICategoryServiceComponent OverrideCheckCategoryServiceHealthQueryHandler<T>() where T : ICheckCategoryServiceHealthQueryHandler;
ICategoryServiceComponent OverrideFetchCategoriesByHandlesQueryHandler<T>() where T : IFetchCategoriesByHandlesQueryHandler;
ICategoryServiceComponent OverrideFetchCategoriesByIdsQueryHandler<T>() where T : IFetchCategoriesByIdsQueryHandler;
ICategoryServiceComponent OverrideFetchCategoriesBySearchQueryHandler<T>() where T : IFetchCategoriesBySearchQueryHandler;
#endregion Query Handlers
#region Command Handlers
ICategoryServiceComponent OverridePersistCategoryCommandHandler<T>() where T : IPersistCategoryCommandHandler;
ICategoryServiceComponent OverrideDeleteCategoryCommandHandler<T>() where T : IDeleteCategoryCommandHandler;
#endregion Command Handlers
}
Register during startup through the UseInMemoryBackend(root, options)
extension on ICategoryServiceComponent
.
root.AddCategoryService(service =>
{
service.UseInMemoryBackend(root, backend =>
{
var categories = new List<Category>();
// ...
backend.UseCategories(categories);
});
// Configure service
// ...
});