feat: Add DuckDB Aspire integration (hosting + client)#1245
Open
lqdev wants to merge 2 commits intoCommunityToolkit:mainfrom
Open
feat: Add DuckDB Aspire integration (hosting + client)#1245lqdev wants to merge 2 commits intoCommunityToolkit:mainfrom
lqdev wants to merge 2 commits intoCommunityToolkit:mainfrom
Conversation
Add first-class Aspire integration for DuckDB using DuckDB.NET, following the embedded database pattern (like SQLite). Hosting integration (CommunityToolkit.Aspire.Hosting.DuckDB): - DuckDBResource with IResourceWithConnectionString support - AddDuckDB() and WithReadOnly() extension methods - File-based persistence with configurable path/filename - Dashboard integration with Running state Client integration (CommunityToolkit.Aspire.DuckDB.NET.Data): - AddDuckDBConnection() and AddKeyedDuckDBConnection() - Scoped DuckDBConnection registration via DI - Custom health check (SELECT 1) - Configuration via Aspire:DuckDB:Client section Also includes: - Example application with analytics API endpoints - 16 hosting tests (unit + integration), 31 client tests - CI pipeline updated with both test projects Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 1245Or
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 1245" |
Author
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new DuckDB integration to the Aspire Community Toolkit, providing both an AppHost (hosting) resource and a client library (DuckDB.NET.Data) registration pattern aligned with the existing embedded DB (SQLite) approach.
Changes:
- Introduces
AddDuckDB()hosting resource +WithReadOnly()support with dashboard state integration. - Adds
AddDuckDBConnection()/AddKeyedDuckDBConnection()client registration with an inline DuckDB health check. - Adds DuckDB example AppHost/API projects plus new hosting/client test projects and wires them into the solution and CI workflow.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/CommunityToolkit.Aspire.Hosting.DuckDB.Tests/CommunityToolkit.Aspire.Hosting.DuckDB.Tests.csproj | Adds hosting DuckDB test project references (src + example AppHost + testing helpers). |
| tests/CommunityToolkit.Aspire.Hosting.DuckDB.Tests/AppHostTests.cs | Adds integration tests validating resource health, connection string shape, and example API endpoints. |
| tests/CommunityToolkit.Aspire.Hosting.DuckDB.Tests/AddDuckDBTests.cs | Adds unit tests for hosting resource defaults, manifest behavior, and read-only mode connection string. |
| tests/CommunityToolkit.Aspire.DuckDB.NET.Data.Tests/DuckDBConnectionTests.cs | Adds client DI registration tests (keyed/non-keyed) using configuration connection strings. |
| tests/CommunityToolkit.Aspire.DuckDB.NET.Data.Tests/ConformanceTests.cs | Adds Aspire conformance-test harness coverage for the DuckDB client integration. |
| tests/CommunityToolkit.Aspire.DuckDB.NET.Data.Tests/ConfigurationTests.cs | Adds client configuration tests (Aspire section + missing connection string behavior). |
| tests/CommunityToolkit.Aspire.DuckDB.NET.Data.Tests/CommunityToolkit.Aspire.DuckDB.NET.Data.Tests.csproj | Adds DuckDB client test project references. |
| src/CommunityToolkit.Aspire.Hosting.DuckDB/README.md | Documents hosting package usage (AddDuckDB, WithReadOnly). |
| src/CommunityToolkit.Aspire.Hosting.DuckDB/DuckDBResourceBuilderExtensions.cs | Implements AddDuckDB resource creation + initial snapshot and pre-start directory/permission setup. |
| src/CommunityToolkit.Aspire.Hosting.DuckDB/DuckDBResource.cs | Defines DuckDB resource + connection string expression and connection properties. |
| src/CommunityToolkit.Aspire.Hosting.DuckDB/CommunityToolkit.Aspire.Hosting.DuckDB.csproj | Adds hosting package project definition and test visibility. |
| src/CommunityToolkit.Aspire.DuckDB.NET.Data/README.md | Documents client package usage (DI registration + injecting DuckDBConnection). |
| src/CommunityToolkit.Aspire.DuckDB.NET.Data/DuckDBConnectionSettings.cs | Adds client settings model (connection string + health check toggle). |
| src/CommunityToolkit.Aspire.DuckDB.NET.Data/CommunityToolkit.Aspire.DuckDB.NET.Data.csproj | Adds DuckDB.NET.Data.Full dependency + shared validation/healthcheck utilities linkage. |
| src/CommunityToolkit.Aspire.DuckDB.NET.Data/AspireDuckDBExtensions.cs | Implements DI registration, config binding precedence, and inline DuckDB health check. |
| examples/duckdb/CommunityToolkit.Aspire.DuckDB.ServiceDefaults/Extensions.cs | Adds example service-defaults wiring (OTel, health checks, service discovery). |
| examples/duckdb/CommunityToolkit.Aspire.DuckDB.ServiceDefaults/CommunityToolkit.Aspire.DuckDB.ServiceDefaults.csproj | Adds example ServiceDefaults project dependencies. |
| examples/duckdb/CommunityToolkit.Aspire.DuckDB.AppHost/Properties/launchSettings.json | Adds example AppHost launch profiles. |
| examples/duckdb/CommunityToolkit.Aspire.DuckDB.AppHost/Program.cs | Adds example AppHost wiring DuckDB resource to the API project reference. |
| examples/duckdb/CommunityToolkit.Aspire.DuckDB.AppHost/CommunityToolkit.Aspire.DuckDB.AppHost.csproj | Adds example DuckDB AppHost project setup and references. |
| examples/duckdb/CommunityToolkit.Aspire.DuckDB.AppHost/appsettings.json | Adds example AppHost logging configuration. |
| examples/duckdb/CommunityToolkit.Aspire.DuckDB.Api/Properties/launchSettings.json | Adds example API launch profiles. |
| examples/duckdb/CommunityToolkit.Aspire.DuckDB.Api/Program.cs | Adds example API endpoints executing DuckDB queries plus seeding logic. |
| examples/duckdb/CommunityToolkit.Aspire.DuckDB.Api/CommunityToolkit.Aspire.DuckDB.Api.csproj | Adds example API project references to client + ServiceDefaults. |
| Directory.Packages.props | Centralizes DuckDB.NET.Data.Full package version. |
| CommunityToolkit.Aspire.slnx | Adds new DuckDB src/test/example projects to the solution. |
| .github/workflows/tests.yaml | Adds the new hosting/client DuckDB test projects to CI test matrix. |
tests/CommunityToolkit.Aspire.DuckDB.NET.Data.Tests/ConfigurationTests.cs
Show resolved
Hide resolved
Accept review suggestion — the ConnectionStringFromConfiguration test now resolves DuckDBConnection from DI and asserts the connection string was properly bound from configuration, rather than just building the host. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Adds first-class Aspire integration for DuckDB using DuckDB.NET, following the embedded database pattern established by the SQLite integration.
DuckDB is a high-performance, in-process OLAP database — ideal for analytics, data science, and ETL workloads within Aspire applications.
New Packages
CommunityToolkit.Aspire.Hosting.DuckDBAddDuckDB(),WithReadOnly(), dashboard integrationCommunityToolkit.Aspire.DuckDB.NET.DataAddDuckDBConnection(), health checks, DI registrationUsage
AppHost (Hosting)
API Service (Client)
Design Decisions
RunningDuckDB.NET.Data.Fullwhich bundles native DuckDB libraries for all platforms (win/linux/mac, x64/arm64)SELECT 1) since no communityAspNetCore.HealthChecks.DuckDBpackage existsWithReadOnly()appendsAccess Mode=ReadOnlyto connection string for read-only scenariosWhat's Included
Source (
src/)CommunityToolkit.Aspire.Hosting.DuckDB—DuckDBResource,DuckDBResourceBuilderExtensionsCommunityToolkit.Aspire.DuckDB.NET.Data—AspireDuckDBExtensions,DuckDBConnectionSettingsExamples (
examples/duckdb/)Tests (
tests/)CI
tests.yamlwithHosting.DuckDB.TestsandDuckDB.NET.Data.TestsTest Results