Get started with the KurrentDB integrations
Konten ini belum tersedia dalam bahasa Anda.
KurrentDB is an event store database designed for Event Sourcing, offering high availability and reliability for storing events. The Aspire KurrentDB integration enables you to connect to existing KurrentDB instances or create new instances from Aspire using the KurrentDB container image.
In this introduction, you’ll see how to install and use the Aspire KurrentDB integrations in a simple configuration. If you already have this knowledge, see KurrentDB hosting integration for full reference details.
Set up hosting integration
Section titled “Set up hosting integration”To begin, install the Aspire KurrentDB hosting integration in your Aspire AppHost project:
aspire add communitytoolkit-kurrentdbAspire CLI interaktif; pilih hasil pencarian yang sesuai saat diminta:
Select an integration to add:
> communitytoolkit-kurrentdb (CommunityToolkit.Aspire.Hosting.KurrentDB)> Other results listed as selectable options...#:package CommunityToolkit.Aspire.Hosting.KurrentDB@*<PackageReference Include="CommunityToolkit.Aspire.Hosting.KurrentDB" Version="*" />In the AppHost project, register and consume the KurrentDB integration using the AddKurrentDB extension method to add the KurrentDB container to the application builder:
var builder = DistributedApplication.CreateBuilder(args);
var kurrentdb = builder.AddKurrentDB("kurrentdb");
builder.AddProject<Projects.ExampleProject>() .WithReference(kurrentdb);
// After adding all resources, run the app...Set up client integration
Section titled “Set up client integration”In the client-consuming project, install the Aspire KurrentDB client integration:
dotnet add package CommunityToolkit.Aspire.KurrentDB#:package CommunityToolkit.Aspire.KurrentDB@*<PackageReference Include="CommunityToolkit.Aspire.KurrentDB" Version="*" />In the Program.cs file of your client-consuming project, call the AddKurrentDBClient extension to register a KurrentDBClient for use via the dependency injection container:
builder.AddKurrentDBClient(connectionName: "kurrentdb");You can then retrieve the KurrentDBClient instance using dependency injection. For example, to retrieve the client from a service:
public class ExampleService(KurrentDBClient client){ // Use client...}For full reference details, see KurrentDB hosting integration and KurrentDB client integration.