Skip to content

Commit

Permalink
Add RavenDB client & hosting integration (#397)
Browse files Browse the repository at this point in the history
* RavenDB-Aspire - Implement RavenDB client & hosting integration

* RavenDB-Aspire - fixed PR comments

* RavenDB-Aspire:
- fix client integration
- change ConnectionStringExpression format to "URL={Url};Database={DatabaseName}"
- expand example to include the client library
- fix README.md files
- fix and add tests

* Update Directory.Packages.props

* RavenDB-Aspire - update CODEOWNERS & README.md

---------

Co-authored-by: Aaron Powell <[email protected]>
  • Loading branch information
shiranshalom and aaronpowell authored Feb 6, 2025
1 parent 834360f commit 7250acb
Show file tree
Hide file tree
Showing 36 changed files with 2,245 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@
/src/CommunityToolkit.Aspire.Hosting.Dapr**/ @FullStackChef @WhitWaldo @Paule96
/tests/CommunityToolkit.Aspire.Hosting.Dapr**.Tests/ @FullStackChef @WhitWaldo @Paule96

# CommunityToolkit.Aspire.RavenDB.Client
# CommunityToolkit.Aspire.Hosting.RavenDB

/examples/ravendb/ @shiranshalom
/src/CommunityToolkit.Aspire.RavenDB.Client/ @shiranshalom
/tests/CommunityToolkit.Aspire.RavenDB.Client.Tests/ @shiranshalom
/src/CommunityToolkit.Aspire.Hosting.RavenDB/ @shiranshalom
/tests/CommunityToolkit.Aspire.Hosting.RavenDB.Tests/ @shiranshalom

# CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions

/src/CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions/ @Alirexaa
Expand Down
51 changes: 51 additions & 0 deletions CommunityToolkit.Aspire.sln
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,21 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hos
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.Dapr.ServiceDefaults", "examples\dapr\CommunityToolkit.Aspire.Hosting.Dapr.ServiceDefaults\CommunityToolkit.Aspire.Hosting.Dapr.ServiceDefaults.csproj", "{99441705-4BFA-499F-9897-371238665E38}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Aspire.RavenDB.Client", "src\CommunityToolkit.Aspire.RavenDB.Client\CommunityToolkit.Aspire.RavenDB.Client.csproj", "{11768120-E86C-4464-A68A-6F9BD0999BB9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Aspire.RavenDB.Client.Tests", "tests\CommunityToolkit.Aspire.RavenDB.Client.Tests\CommunityToolkit.Aspire.RavenDB.Client.Tests.csproj", "{BA416CE7-0C29-4FBA-B31A-327A7ECB56C9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Aspire.Hosting.RavenDB", "src\CommunityToolkit.Aspire.Hosting.RavenDB\CommunityToolkit.Aspire.Hosting.RavenDB.csproj", "{A7852D8B-BE38-4D95-A8D6-3B6F96F94A5A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Aspire.Hosting.RavenDB.Tests", "tests\CommunityToolkit.Aspire.Hosting.RavenDB.Tests\CommunityToolkit.Aspire.Hosting.RavenDB.Tests.csproj", "{35B51242-F576-4CCE-BA29-712A80749CB1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ravendb", "ravendb", "{1C65F967-D5F1-424B-82E9-B8585B6F0BD6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.RavenDB.AppHost", "examples\ravendb\RavenDB.AppHost\CommunityToolkit.Aspire.Hosting.RavenDB.AppHost.csproj", "{28FCB1E2-7460-4FDD-AA63-03162C9F2154}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.RavenDB.ServiceDefaults", "examples\ravendb\CommunityToolkit.Aspire.Hosting.RavenDB.ServiceDefaults\CommunityToolkit.Aspire.Hosting.RavenDB.ServiceDefaults.csproj", "{3D076CFF-6482-4126-9F29-C7617E7D2F5B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.RavenDB.ApiService", "examples\ravendb\CommunityToolkit.Aspire.Hosting.RavenDB.ApiService\CommunityToolkit.Aspire.Hosting.RavenDB.ApiService.csproj", "{D214CBF5-D5E4-4641-868D-66B0C5337DD5}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.DbGate.Tests", "tests\CommunityToolkit.Aspire.Hosting.DbGate.Tests\CommunityToolkit.Aspire.Hosting.DbGate.Tests.csproj", "{BDAF7D27-C600-4419-9782-CF15BA5272E9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "postgres-ext", "postgres-ext", "{204BB8D8-04E3-4FE5-BB08-E793BF532F2F}"
Expand Down Expand Up @@ -721,6 +736,34 @@ Global
{99441705-4BFA-499F-9897-371238665E38}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99441705-4BFA-499F-9897-371238665E38}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99441705-4BFA-499F-9897-371238665E38}.Release|Any CPU.Build.0 = Release|Any CPU
{11768120-E86C-4464-A68A-6F9BD0999BB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11768120-E86C-4464-A68A-6F9BD0999BB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11768120-E86C-4464-A68A-6F9BD0999BB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11768120-E86C-4464-A68A-6F9BD0999BB9}.Release|Any CPU.Build.0 = Release|Any CPU
{BA416CE7-0C29-4FBA-B31A-327A7ECB56C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA416CE7-0C29-4FBA-B31A-327A7ECB56C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA416CE7-0C29-4FBA-B31A-327A7ECB56C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA416CE7-0C29-4FBA-B31A-327A7ECB56C9}.Release|Any CPU.Build.0 = Release|Any CPU
{A7852D8B-BE38-4D95-A8D6-3B6F96F94A5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A7852D8B-BE38-4D95-A8D6-3B6F96F94A5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A7852D8B-BE38-4D95-A8D6-3B6F96F94A5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A7852D8B-BE38-4D95-A8D6-3B6F96F94A5A}.Release|Any CPU.Build.0 = Release|Any CPU
{35B51242-F576-4CCE-BA29-712A80749CB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35B51242-F576-4CCE-BA29-712A80749CB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35B51242-F576-4CCE-BA29-712A80749CB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35B51242-F576-4CCE-BA29-712A80749CB1}.Release|Any CPU.Build.0 = Release|Any CPU
{28FCB1E2-7460-4FDD-AA63-03162C9F2154}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28FCB1E2-7460-4FDD-AA63-03162C9F2154}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28FCB1E2-7460-4FDD-AA63-03162C9F2154}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28FCB1E2-7460-4FDD-AA63-03162C9F2154}.Release|Any CPU.Build.0 = Release|Any CPU
{3D076CFF-6482-4126-9F29-C7617E7D2F5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D076CFF-6482-4126-9F29-C7617E7D2F5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D076CFF-6482-4126-9F29-C7617E7D2F5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D076CFF-6482-4126-9F29-C7617E7D2F5B}.Release|Any CPU.Build.0 = Release|Any CPU
{D214CBF5-D5E4-4641-868D-66B0C5337DD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D214CBF5-D5E4-4641-868D-66B0C5337DD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D214CBF5-D5E4-4641-868D-66B0C5337DD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D214CBF5-D5E4-4641-868D-66B0C5337DD5}.Release|Any CPU.Build.0 = Release|Any CPU
{BDAF7D27-C600-4419-9782-CF15BA5272E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BDAF7D27-C600-4419-9782-CF15BA5272E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BDAF7D27-C600-4419-9782-CF15BA5272E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -890,6 +933,14 @@ Global
{D2DDEA96-4A7E-496B-AFBE-69A133156C5F} = {E3C2B4B7-B3B0-4E7F-A975-A6C7FD926792}
{5ADBE907-7E0B-4AD7-9073-C032C4183914} = {E3C2B4B7-B3B0-4E7F-A975-A6C7FD926792}
{99441705-4BFA-499F-9897-371238665E38} = {E3C2B4B7-B3B0-4E7F-A975-A6C7FD926792}
{11768120-E86C-4464-A68A-6F9BD0999BB9} = {414151D4-7009-4E78-A5C6-D99EBD1E67D1}
{BA416CE7-0C29-4FBA-B31A-327A7ECB56C9} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
{A7852D8B-BE38-4D95-A8D6-3B6F96F94A5A} = {414151D4-7009-4E78-A5C6-D99EBD1E67D1}
{35B51242-F576-4CCE-BA29-712A80749CB1} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
{1C65F967-D5F1-424B-82E9-B8585B6F0BD6} = {8519CC01-1370-47C8-AD94-B0F326B1563F}
{28FCB1E2-7460-4FDD-AA63-03162C9F2154} = {1C65F967-D5F1-424B-82E9-B8585B6F0BD6}
{3D076CFF-6482-4126-9F29-C7617E7D2F5B} = {1C65F967-D5F1-424B-82E9-B8585B6F0BD6}
{D214CBF5-D5E4-4641-868D-66B0C5337DD5} = {1C65F967-D5F1-424B-82E9-B8585B6F0BD6}
{BDAF7D27-C600-4419-9782-CF15BA5272E9} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
{204BB8D8-04E3-4FE5-BB08-E793BF532F2F} = {8519CC01-1370-47C8-AD94-B0F326B1563F}
{356853EE-2C47-429C-B6CF-F3F76B6FFD91} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
Expand Down
3 changes: 3 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
<PackageVersion Include="EventStore.Client.Grpc.Streams" Version="23.3.8" />
<PackageVersion Include="MassTransit.RabbitMQ" Version="8.3.2" />
<PackageVersion Include="ErikEJ.Dacpac.Chinook" Version="1.0.0" />
<PackageVersion Include="RavenDB.Client" Version="6.2.1" />
<PackageVersion Include="RavenDB.TestDriver" Version="6.2.1" />
<PackageVersion Include="AspNetCore.HealthChecks.RavenDB" Version="9.0.0" />
<!-- Build dependencies -->
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
<!-- Testcontainers packages -->
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ This repository contains the source code for the .NET Aspire Community Toolkit,
| - **Learn More**: [`Microsoft.EntityFrameworkCore.Sqlite`][sqlite-ef-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite][sqlite-ef-shields]][sqlite-ef-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite][sqlite-ef-shields-preview]][sqlite-ef-nuget-preview] | An Aspire client integration for the Microsoft.EntityFrameworkCore.Sqlite NuGet package. |
| - **Learn More**: [`Hosting.Dapr`][dapr-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.Hosting.Dapr][dapr-shields]][dapr-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.Hosting.Dapr][dapr-shields-preview]][dapr-nuget-preview] | An Aspire hosting integration for Dapr. |
| - **Learn More**: [`Hosting.Dapr.AzureRedis`][dapr-azureredis-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis][dapr-azureredis-shields]][dapr-azureredis-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis][dapr-azureredis-shields-preview]][dapr-azureredis-nuget-preview] | An extension for the Dapr hosting integration for using Dapr with Azure Redis cache. |
| - **Learn More**: [`Hosting.RavenDB`][ravendb-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.Hosting.RavenDB][ravendb-shields]][ravendb-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.Hosting.RavenDB][ravendb-shields-preview]][ravendb-nuget-preview] | An Aspire integration leveraging the [RavenDB](https://ravendb.net/) container. |
| - **Learn More**: [`RavenDB.Client`][ravendb-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.RavenDB.Client][ravendb-client-shields]][ravendb-client-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.RavenDB.Client][ravendb-client-shields-preview]][ravendb-client-nuget-preview] | An Aspire client integration for the [RavenDB.Client](https://www.nuget.org/packages/RavenDB.client) package. |
| - **Learn More**: [`Hosting.GoFeatureFlag`][go-feature-flag-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.Hosting.GoFeatureFlag][go-feature-flag-shields]][go-feature-flag-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.Hosting.GoFeatureFlag][go-feature-flag-shields-preview]][go-feature-flag-nuget-preview] | An Aspire hosting integration leveraging the [GoFeatureFlag](https://gofeatureflag.org/) container. |
| - **Learn More**: [`GoFeatureFlag`][go-feature-flag-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.GoFeatureFlag][go-feature-flag-client-shields]][go-feature-flag-client-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.GoFeatureFlag][go-feature-flag-client-shields-preview]][go-feature-flag-client-nuget-preview] | An Aspire client integration for the [GoFeatureFlag](https://github.com/open-feature/dotnet-sdk-contrib/tree/main/src/OpenFeature.Contrib.Providers.GOFeatureFlag) package. |

Expand Down Expand Up @@ -184,6 +186,15 @@ This project is supported by the [.NET Foundation](https://dotnetfoundation.org)
[dapr-azureredis-nuget]: https://nuget.org/packages/CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis/
[dapr-azureredis-shields-preview]: https://img.shields.io/nuget/vpre/CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis?label=nuget%20(preview)
[dapr-azureredis-nuget-preview]: https://nuget.org/packages/CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis/absoluteLatest
[ravendb-integration-docs]: https://learn.microsoft.com/dotnet/aspire/community-toolkit/ravendb
[ravendb-shields]: https://img.shields.io/nuget/v/CommunityToolkit.Aspire.Hosting.RavenDB
[ravendb-nuget]: https://nuget.org/packages/CommunityToolkit.Aspire.Hosting.RavenDB/
[ravendb-shields-preview]: https://img.shields.io/nuget/vpre/CommunityToolkit.Aspire.Hosting.RavenDB?label=nuget%20(preview)
[ravendb-nuget-preview]: https://nuget.org/packages/CommunityToolkit.Aspire.Hosting.RavenDB/absoluteLatest
[ravendb-client-shields]: https://img.shields.io/nuget/v/CommunityToolkit.Aspire.RavenDB.Client
[ravendb-client-nuget]: https://nuget.org/packages/CommunityToolkit.Aspire.RavenDB.Client/
[ravendb-client-shields-preview]: https://img.shields.io/nuget/vpre/CommunityToolkit.Aspire.RavenDB.Client?label=nuget%20(preview)
[ravendb-client-nuget-preview]: https://nuget.org/packages/CommunityToolkit.Aspire.RavenDB.Client/absoluteLatest
[go-feature-flag-integration-docs]: https://learn.microsoft.com/dotnet/aspire/community-toolkit/hosting-go-feature-flag
[go-feature-flag-shields]: https://img.shields.io/nuget/v/CommunityToolkit.Aspire.Hosting.GoFeatureFlag
[go-feature-flag-nuget]: https://nuget.org/packages/CommunityToolkit.Aspire.Hosting.GoFeatureFlag/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\CommunityToolkit.Aspire.RavenDB.Client\CommunityToolkit.Aspire.RavenDB.Client.csproj" />
<ProjectReference Include="..\CommunityToolkit.Aspire.Hosting.RavenDB.ServiceDefaults\CommunityToolkit.Aspire.Hosting.RavenDB.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Raven.Client.Documents;

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();
builder.AddRavenDBClient(connectionName: "ravendb", configureSettings: settings =>
{
settings.CreateDatabase = true;
settings.DatabaseName = "ravenDatabase";
});

var app = builder.Build();

app.MapGet("/create", async (IDocumentStore documentStore) =>
{
using var session = documentStore.OpenAsyncSession();
var company = new Company
{
Name = "RavenDB",
Phone = "(26) 642-7012",
Fax = "(26) 642-7012"
};

await session.StoreAsync(company, "companies/ravendb");
await session.SaveChangesAsync();
});

app.MapGet("/get", async (IDocumentStore documentStore) =>
{
using var session = documentStore.OpenAsyncSession();
var company = await session.LoadAsync<Company>("companies/ravendb");
return company;
});

app.MapDefaultEndpoints();

app.Run();


public class Company
{
public string? Id { get; set; }
public string? Name { get; set; }
public string? Phone { get; set; }
public string? Fax { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"profiles": {
"CommunityToolkit.Aspire.Hosting.RavenDB.ApiService": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:54649"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@ApiService_HostAddress = http://localhost:54649

GET {{ApiService_HostAddress}}/
Accept: application/json

###
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireSharedProject>true</IsAspireSharedProject>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
</ItemGroup>

</Project>
Loading

0 comments on commit 7250acb

Please sign in to comment.