Skip to content

spike: FromEnd (last-N) query offset — design validation (DO NOT MERGE) - #457

Draft
Aaronontheweb wants to merge 1 commit into
akkadotnet:devfrom
Aaronontheweb:spike/fromend-offset
Draft

spike: FromEnd (last-N) query offset — design validation (DO NOT MERGE)#457
Aaronontheweb wants to merge 1 commit into
akkadotnet:devfrom
Aaronontheweb:spike/fromend-offset

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Member

Summary

Proof-of-concept implementation of Offset.FromEnd(N) for the MongoDB read journal, parallel to the SQL spike in akkadotnet/Akka.Persistence.Sql#589.

  • MongoDbJournalQueries.FromEndOrderingQuery — sort descending, skip N, take 1 to find the exclusive-start anchor ordering value (the event immediately before the last-N window)
  • MongoDbJournal — handles new FindFromEndOffset ask message and delegates to the queries layer
  • MongoDbReadJournal — adds ResolveFromEnd helper (Ask → ConcatMany) and a FromEnd case to all 4 query methods (AllEvents, CurrentAllEvents, EventsByTag, CurrentEventsByTag)
  • MongoDbFromEndOffsetSpec — wires the new Akka.Persistence.TCK.FromEndOffsetSpec against an in-process MongoDB instance (Mongo2Go) with ColorFruitTagger
  • Bumps to Akka.NET 1.5.70-beta1 which carries the FromEnd type in Akka.Persistence.Query; AkkaHostingVersion stays at 1.5.67 (no Hosting beta1 published yet)

Relates to akkadotnet/akka.net#8244

DO NOT MERGE — spike/design validation only

@Aaronontheweb

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

…(DO NOT MERGE)

Implements Offset.FromEnd(N) in MongoDbReadJournal for AllEvents, CurrentAllEvents,
EventsByTag, and CurrentEventsByTag. Resolves FromEnd to a concrete BsonTimestamp
ordering value by finding the Nth-from-last matching document.

- MongoDbJournalQueries.FromEndOrderingQuery: sort desc, skip N, take 1 to find
  the exclusive-start anchor ordering value (N events before the window).
- MongoDbJournal: handles FindFromEndOffset ask message, delegates to queries layer.
- MongoDbReadJournal: adds ResolveFromEnd helper (Ask → ConcatMany) and FromEnd
  case to all 4 query methods (AllEvents, CurrentAllEvents, EventsByTag,
  CurrentEventsByTag).
- MongoDbFromEndOffsetSpec: wires the new Akka.Persistence.TCK FromEndOffsetSpec
  against a Mongo2Go in-process MongoDB instance with ColorFruitTagger.
- Bumps to Akka.NET 1.5.70-beta1 which carries the FromEnd type; AkkaHostingVersion
  stays at 1.5.67 (no Hosting beta1 published yet).

Relates to akkadotnet/akka.net#8244
@Aaronontheweb
Aaronontheweb force-pushed the spike/fromend-offset branch from 3a9c206 to f205a4d Compare June 23, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant