-
Notifications
You must be signed in to change notification settings - Fork 3
Configuration
A. Shafie edited this page Nov 24, 2023
·
7 revisions
LiteBus
has different Nuget Packages for its various modules and features. Add these packages to your project as needed:
-
LiteBus
- Contains all feature implementations. -
LiteBus.Extensions.MicrosoftDependencyInjection
- Integrates with Microsoft Dependency Injection. Suitable for ASP.NET Core applications.
These packages provide components for handling commands, which include:
-
ICommand
: A command without a result. -
ICommand<TResult>
: A command that returns a result.
-
LiteBus.Commands.Abstractions
- Holds abstractions likeICommand
, andICommand<TResult>
. -
LiteBus.Commands
- Contains the command implementations. -
LiteBus.Commands.Extensions.MicrosoftDependencyInjection
- Integrates with Microsoft Dependency Injection. Suitable for ASP.NET Core projects.
These packages provide components for handling queries, including:
-
IQuery<TResult>
: Standard query. -
IStreamQuery<TResult>
: Query that yieldsIAsyncEnumerable<TResult>
.
-
LiteBus.Queries.Abstractions
- Contains abstractions likeIQuery<TResult>
andIStreamQuery<TResult>
. -
LiteBus.Queries
- Holds the query implementations. -
LiteBus.Queries.Extensions.MicrosoftDependencyInjection
- Integrates with Microsoft Dependency Injection.
These packages offer components for handling events:
-
IEvent
: Represents an event.
-
LiteBus.Events.Abstractions
- Contains event abstractions likeIEvent
. -
LiteBus.Events
- Implements the events. -
LiteBus.Events.Extensions.MicrosoftDependencyInjection
- Integrates with Microsoft Dependency Injection.
To set up LiteBus
modules for ASP.NET Core, use the ConfigureServices
method in Startup.cs
:
services.AddLiteBus(builder =>
{
builder.AddCommandModule(builder =>
{
builder.RegisterFromAssembly(typeof(CreateProductCommand).Assembly) // Registers all handlers from a specific assembly.
.Register<ProductValidationHandler>()
.Register<ProductAuditingHandler>();
})
.AddQueryModule(builder =>
{
builder.RegisterFromAssembly(typeof(GetAllProducts).Assembly);
})
.AddEventModule(builder =>
{
builder.RegisterFromAssembly(typeof(ProductCreatedEvent).Assembly);
});
});
RegisterFromAssembly
: This method registers all handlers from a specified assembly.
Register<T>
: This method registers a specific handler. Any type of handler or message can be registered via this method.
- Command Contracts
- Command Handler Contracts
- Command Main Handlers
- Command Mediator
- Command Pre Handlers
- Command Post-Handlers
- Command Error Handlers
- Query Contracts
- Query Handler Contracts
- Query Main Handlers
- Query Mediator
- Query Pre Handlers
- Query Post-Handlers
- Query Error Handlers