From 742de4b6cc7a16ac6dff7f69b4971264a21a06fe Mon Sep 17 00:00:00 2001 From: "Jeremy D. Miller" Date: Wed, 27 May 2026 17:34:19 -0500 Subject: [PATCH] Override IEventStore.AllDatabases() on DocumentStore; consume JasperFx 2.2.0 (#4570) Implements the store-agnostic database accessor added to JasperFx.Events.IEventStore in jasperfx#387/#388. Marten + Wolverine hosts register IEventStore (the concrete DocumentStore) in DI but not IEventDatabase, so store-neutral tooling (e.g. CritterWatch) had no way to reach the per-database read abstractions. AllDatabases() delegates straight to ITenancy, mirroring IMartenStorage.AllDatabases(), and projects to IEventDatabase (IMartenDatabase does not itself extend it). Also bumps all JasperFx.* packages to 2.2.0 and the Marten version to 9.2.0. Co-Authored-By: Claude Opus 4.7 (1M context) --- Directory.Build.props | 2 +- Directory.Packages.props | 8 ++++---- src/Marten/DocumentStore.EventStore.cs | 9 +++++++++ ...umentStore_IMartenStorage_implementation.cs | 18 ++++++++++++++++++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 25df7aca01..c3fda3772e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 9.0.2 + 9.2.0 13.0 Jeremy D. Miller;Babu Annamalai;Jaedyn Tonee https://martendb.io/logo.png diff --git a/Directory.Packages.props b/Directory.Packages.props index 9d63e2b1c7..6bb7227f1e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -13,13 +13,13 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/Marten/DocumentStore.EventStore.cs b/src/Marten/DocumentStore.EventStore.cs index cad23dd5bd..740807cb38 100644 --- a/src/Marten/DocumentStore.EventStore.cs +++ b/src/Marten/DocumentStore.EventStore.cs @@ -65,6 +65,15 @@ bool IEventStore.HasMultipleTenants } } + async ValueTask> IEventStore.AllDatabases() + { + // Straight delegation to ITenancy, mirroring IMartenStorage.AllDatabases(). The IMartenDatabase + // interface does not itself extend IEventDatabase (only the concrete MartenDatabase does), so this + // projects rather than returning the list directly. See #4570. + var databases = await Tenancy.BuildDatabases().ConfigureAwait(false); + return databases.OfType().ToList(); + } + public EventStoreIdentity Identity { get; } IEventRegistry IEventStore.Registry => Options.EventGraph; diff --git a/src/MultiTenancyTests/DocumentStore_IMartenStorage_implementation.cs b/src/MultiTenancyTests/DocumentStore_IMartenStorage_implementation.cs index d293be56a0..ca11b201cd 100644 --- a/src/MultiTenancyTests/DocumentStore_IMartenStorage_implementation.cs +++ b/src/MultiTenancyTests/DocumentStore_IMartenStorage_implementation.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Threading.Tasks; using JasperFx.Core; +using JasperFx.Events; using Marten; using Marten.Testing.Documents; using Marten.Testing.Harness; @@ -155,6 +156,23 @@ public async Task all_databases_can_return() var databases = await theStore.Storage.AllDatabases(); databases.Count.ShouldBe(3); } + + [Fact] + public async Task event_store_all_databases_returns_one_event_database_per_database() + { + // IEventStore.AllDatabases() is the store-agnostic mirror of IMartenStorage.AllDatabases() (#4570). + // A Marten + Wolverine host registers IEventStore (the concrete DocumentStore) in DI but not + // IEventDatabase, so this is how store-neutral tooling reaches every database. + var databases = await ((IEventStore)theStore).AllDatabases(); + databases.Count.ShouldBe(3); + + // Each IEventDatabase can serve the store-neutral read abstractions + foreach (var database in databases) + { + (await database.AllProjectionProgress()).ShouldNotBeNull(); + (await database.FetchDeadLetterCountsAsync()).ShouldNotBeNull(); + } + } } public record RandomEvent{}