Skip to content

Commit a596877

Browse files
committed
feat: Enable Marten event store archived stream partitioning, event skipping, and quick append mode.
1 parent e462662 commit a596877

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/BookStore.ApiService/Infrastructure/Extensions/MartenConfigurationExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,16 @@ public static IServiceCollection AddMartenEventStore(
5050

5151
// 50% improvement in throughput, less "event skipping"
5252
options.Events.AppendMode = EventAppendMode.Quick;
53+
options.Events.UseArchivedStreamPartitioning = true;
5354

5455
// These cause some database changes, so can't be defaults,
5556
// but these might help "heal" systems that have problems later
5657
options.Events.EnableAdvancedAsyncTracking = true;
5758

59+
// Enables you to mark events as just plain bad so they are skipped
60+
// in projections from here on out.
61+
options.Events.EnableEventSkippingInProjectionsOrSubscriptions = true;
62+
5863
// This will optimize the usage of Inline projections, but will force
5964
// you to treat your aggregate projection "write models" as being
6065
// immutable in your command handler code
@@ -171,7 +176,6 @@ static void RegisterEventTypes(StoreOptions options)
171176
_ = options.Events.AddEventType<Events.PublisherAdded>();
172177
_ = options.Events.AddEventType<Events.PublisherUpdated>();
173178
_ = options.Events.AddEventType<Events.PublisherSoftDeleted>();
174-
_ = options.Events.AddEventType<Events.PublisherSoftDeleted>();
175179
_ = options.Events.AddEventType<Events.PublisherRestored>();
176180

177181
// User events

tests/BookStore.AppHost.Tests/AdminTenantTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using BookStore.ApiService.Models;
33
using BookStore.Client;
44
using BookStore.Shared.Models;
5+
using JasperFx.Events;
56
using Marten;
67
using Refit;
78
using Weasel.Core;
@@ -142,6 +143,11 @@ public async Task CreateTenant_WithEmailVerification_CreatesUnconfirmedUser()
142143
opts.Connection(connectionString!);
143144
opts.UseSystemTextJsonForSerialization(EnumStorage.AsString, Casing.CamelCase);
144145
_ = opts.Policies.AllDocumentsAreMultiTenanted();
146+
147+
opts.Events.AppendMode = EventAppendMode.Quick;
148+
opts.Events.UseArchivedStreamPartitioning = true;
149+
opts.Events.EnableEventSkippingInProjectionsOrSubscriptions = true;
150+
145151
opts.Events.TenancyStyle = Marten.Storage.TenancyStyle.Conjoined;
146152
});
147153

tests/BookStore.AppHost.Tests/GlobalSetup.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using BookStore.Shared.Models;
77
using JasperFx;
88
using JasperFx.Core;
9+
using JasperFx.Events;
910
using Marten;
1011
using Microsoft.Extensions.Logging;
1112
using Projects;
@@ -94,8 +95,11 @@ static async Task AuthenticateAdminAsync()
9495

9596
opts.Connection(connectionString);
9697
_ = opts.Policies.AllDocumentsAreMultiTenanted();
97-
// Configure Multi-Tenancy (Conjoined)
98-
_ = opts.Policies.AllDocumentsAreMultiTenanted();
98+
99+
opts.Events.AppendMode = EventAppendMode.Quick;
100+
opts.Events.UseArchivedStreamPartitioning = true;
101+
opts.Events.EnableEventSkippingInProjectionsOrSubscriptions = true;
102+
99103
opts.Events.MetadataConfig.CorrelationIdEnabled = true;
100104
opts.Events.MetadataConfig.CausationIdEnabled = true;
101105
opts.Events.MetadataConfig.HeadersEnabled = true;

0 commit comments

Comments
 (0)