Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,20 @@
half (a timed-out blue/green side-effect gate re-reads progression and succeeds when the replay
had already reached the mark, plus a configurable DaemonSettings.SideEffectGateTimeout),
jasperfx#595 (BatchingChannel could deliver its trailing batch twice on shutdown) and #597. -->
<PackageVersion Include="JasperFx" Version="2.37.0" />
<PackageVersion Include="JasperFx.Events" Version="2.37.0" />
<PackageVersion Include="JasperFx.Events.SourceGenerator" Version="2.37.0">
<PackageVersion Include="JasperFx" Version="2.37.1" />
<PackageVersion Include="JasperFx.Events" Version="2.37.1" />
<!--
The shared cross-store event sourcing compliance suites (#5116). Source-only package: the
suites compile inside EventSourcingTests so JasperFx's aggregate source generator can bind
Marten's own session types. Marten.Testing needs it too because MartenComplianceFixture,
which closes the seam, lives beside the rest of the harness.
-->
<PackageVersion Include="JasperFx.Events.ComplianceTests" Version="2.37.1" />
<PackageVersion Include="JasperFx.Events.SourceGenerator" Version="2.37.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="JasperFx.SourceGenerator" Version="2.37.0" />
<PackageVersion Include="JasperFx.SourceGenerator" Version="2.37.1" />
<PackageVersion Include="Jil" Version="3.0.0-alpha2" />
<PackageVersion Include="Lamar" Version="7.1.1" />
<PackageVersion Include="Lamar.Microsoft.DependencyInjection" Version="15.0.0" />
Expand Down
22 changes: 11 additions & 11 deletions docs/events/dcb.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private void ConfigureStore()
});
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_tag_query_and_consistency_tests.cs#L68-L87' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_registering_tag_types' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_documentation_samples.cs#L77-L96' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_registering_tag_types' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Each tag type gets its own table (`mt_event_tag_student`, `mt_event_tag_course`, etc.) with a composite primary key of `(value, seq_id)`.
Expand Down Expand Up @@ -75,7 +75,7 @@ Tag types should be simple wrapper records around a primitive value:
public record StudentId(Guid Value);
public record CourseId(Guid Value);
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_tag_query_and_consistency_tests.cs#L18-L22' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_tag_type_definitions' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_documentation_samples.cs#L16-L20' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_tag_type_definitions' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Supported inner value types: `Guid`, `string`, `int`, `long`, `short`.
Expand All @@ -94,7 +94,7 @@ enrolled.WithTag(studentId, courseId);
theSession.Events.Append(streamId, enrolled);
await theSession.SaveChangesAsync();
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_tag_query_and_consistency_tests.cs#L112-L117' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_tagging_events' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_documentation_samples.cs#L113-L118' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_tagging_events' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Events can have multiple tags of different types. Tags are persisted to their respective tag tables in the same transaction as the event.
Expand All @@ -109,7 +109,7 @@ Use `EventTagQuery` to build a query, then execute it with `QueryByTagsAsync`:
var query = new EventTagQuery().Or<StudentId>(studentId);
var events = await theSession.Events.QueryByTagsAsync(query);
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_tag_query_and_consistency_tests.cs#L119-L122' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_query_by_single_tag' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_documentation_samples.cs#L120-L123' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_query_by_single_tag' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

### Multiple Tags (OR)
Expand All @@ -124,7 +124,7 @@ var query = new EventTagQuery()

var events = await theSession.Events.QueryByTagsAsync(query);
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_tag_query_and_consistency_tests.cs#L149-L156' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_query_multiple_tags_or' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_documentation_samples.cs#L146-L153' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_query_multiple_tags_or' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

### Filtering by Event Type
Expand All @@ -138,7 +138,7 @@ var query = new EventTagQuery()

var events = await theSession.Events.QueryByTagsAsync(query);
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_tag_query_and_consistency_tests.cs#L176-L182' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_query_by_event_type' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_documentation_samples.cs#L173-L179' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_query_by_event_type' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Events are always returned ordered by sequence number (global append order).
Expand Down Expand Up @@ -176,7 +176,7 @@ public class StudentCourseEnrollment
}
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_tag_query_and_consistency_tests.cs#L37-L63' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_aggregate' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_documentation_samples.cs#L35-L61' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_aggregate' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Then aggregate across streams by tag query:
Expand All @@ -190,7 +190,7 @@ var query = new EventTagQuery()

var aggregate = await theSession.Events.AggregateByTagsAsync<StudentCourseEnrollment>(query);
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_tag_query_and_consistency_tests.cs#L222-L228' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_aggregate_by_tags' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_documentation_samples.cs#L200-L206' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_aggregate_by_tags' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Returns `null` if no matching events are found.
Expand Down Expand Up @@ -250,7 +250,7 @@ boundary.AppendOne(assignment);
// appended matching events after our read
await session2.SaveChangesAsync();
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_tag_query_and_consistency_tests.cs#L258-L276' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_fetch_for_writing_by_tags' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_documentation_samples.cs#L226-L244' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_fetch_for_writing_by_tags' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

### Handling Concurrency Violations
Expand All @@ -269,7 +269,7 @@ catch (DcbConcurrencyException ex)
// ex.LastSeenSequence -- the sequence at time of read
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_tag_query_and_consistency_tests.cs#L313-L324' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_handling_concurrency' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_documentation_samples.cs#L281-L292' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_handling_concurrency' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

::: tip
Expand Down Expand Up @@ -313,7 +313,7 @@ public async Task events_exist_returns_true_when_matching_events_found()
exists.ShouldBeTrue();
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_tag_query_and_consistency_tests.cs#L520-L538' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_events_exist_async' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/EventSourcingTests/Dcb/dcb_documentation_samples.cs#L295-L313' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_marten_dcb_events_exist_async' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

This is useful for guard clauses and validation logic in DCB workflows where you need to check preconditions before appending new events.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using System.Threading.Tasks;
using JasperFx.Events;
using JasperFx.Events.ComplianceTests;
using Marten;
using Marten.Testing.Harness;
using Shouldly;
Expand Down Expand Up @@ -36,7 +37,7 @@ public async Task auto_discovered_type_works_for_live_aggregation()
{
// No explicit Snapshot<T>() registration — relies on auto-discovery
var streamId = Guid.NewGuid();
theSession.Events.StartStream(streamId, new AEvent(), new BEvent(), new CEvent());
theSession.Events.StartStream(streamId, new EvolveAEvent(), new EvolveBEvent(), new EvolveCEvent());
await theSession.SaveChangesAsync();

var aggregate = await theSession.Events.AggregateStreamAsync<MutableIEventEvolveAggregate>(streamId);
Expand Down
Loading
Loading