Перейти до вмісту

Get started with the KurrentDB integrations

Цей контент ще не доступний вашою мовою.

⭐ Community Toolkit KurrentDB logo

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.

To begin, install the Aspire KurrentDB hosting integration in your Aspire AppHost project:

Aspire CLI — Додати пакет CommunityToolkit.Aspire.Hosting.KurrentDB
aspire add communitytoolkit-kurrentdb

Aspire CLI інтерактивний; оберіть відповідний результат пошуку:

Aspire CLI — Приклад виводу
Select an integration to add:
> communitytoolkit-kurrentdb (CommunityToolkit.Aspire.Hosting.KurrentDB)
> Other results listed as selectable options...

In the AppHost project, register and consume the KurrentDB integration using the AddKurrentDB extension method to add the KurrentDB container to the application builder:

C# — AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var kurrentdb = builder.AddKurrentDB("kurrentdb");
builder.AddProject<Projects.ExampleProject>()
.WithReference(kurrentdb);
// After adding all resources, run the app...

In the client-consuming project, install the Aspire KurrentDB client integration:

.NET CLI — Add CommunityToolkit.Aspire.KurrentDB package
dotnet add package CommunityToolkit.Aspire.KurrentDB

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:

C# — Program.cs
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.