Skip to content

Dedupe follow-up: ProjectionCoordinatorBase (#4516) + HiloSequenceBase (#4527)#4532

Merged
jeremydmiller merged 2 commits into
masterfrom
feat/dedupe-heavy-refactors-coordinator-hilo-versioning
May 20, 2026
Merged

Dedupe follow-up: ProjectionCoordinatorBase (#4516) + HiloSequenceBase (#4527)#4532
jeremydmiller merged 2 commits into
masterfrom
feat/dedupe-heavy-refactors-coordinator-hilo-versioning

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

The two mechanical "lift-consume" refactors deferred from #4529. Each is a separate commit; both delete a Marten implementation in favor of the lifted JasperFx/Weasel base with behavior preserved verbatim. Closes #4516 and #4527.

#4516 — ProjectionCoordinator → ProjectionCoordinatorBase

#326 lifted the leadership-election + agent-lifecycle loop into JasperFx.Events.Daemon.ProjectionCoordinatorBase. Marten's coordinator is now a subclass:

  • base ctor gets BuildDistributor(store), the store's ResiliencePipeline, Events.TimeProvider, and the three settings (LeadershipPollingTime as TimeSpan, AgentPauseTime, HealthCheckPollingTime);
  • seams implemented: ResolveDaemon (keeps Marten's ImHashMap + double-checked-lock daemon cache) + ResolvedDaemons; existing DaemonForMainDatabase / DaemonForDatabase / AllDaemonsAsync retained;
  • deleted the lifted-into-base members (executeAsync, start/stopAgentsIfNecessary, tryStartAgent, Start/Pause/Resume/Stop bodies, pauseDistributor, DaemonShardName).

#4527 — HiloSequence → Weasel.Core.Sequences.HiloSequenceBase

weasel#287 lifted the Hi-Lo state + client-side arithmetic into Weasel.Core.Sequences. (The serialization-enum subset of #4527 already landed in #4529.)

  • HiloSequence now derives from HiloSequenceBase, keeping only the PostgreSQL I/O (mt_get_next_hi function, mt_hilo floor update); the arithmetic is inherited verbatim — id allocation unchanged;
  • deleted Marten's ISequence / IReadOnlyHiloSettings / HiloSettings / HiloSequenceAdvanceToNextHiAttemptsExceededException copies, aliased the old names via the shared dedupe file (shapes identical);
  • AdvanceToNextHiSync is protected on the base; the one test driving it directly now invokes it reflectively to keep exercising the sync I/O path.

Test plan

  • dotnet build src/Marten.slnx -c Release — 0 errors (net9 + net10).
  • DaemonTests — 185/0/0; HotCold leadership-election (detect_high_water_mark, end_to_end_with_events_already_published) pass.
  • DocumentDbTests Hi-Lo / sequence-id tests — 32/0.
  • CoreTests Sequences + bootstrapping — 25/0.
  • Full CI matrix.

Not in this PR

#4526/#4528 (IRevisioned int-revert + new ILongVersioned codegen/concurrency path) is a feature-grade change with its own test matrix (incl. a Version > Int32 case) — it gets a separate focused PR.

Refs [Master] Marten 9.0 (#4349) · pillar #214.

🤖 Generated with Claude Code

jeremydmiller and others added 2 commits May 20, 2026 10:58
…bclass

#326 lifted the projection-coordinator execute loop + agent-start
resilience + lifecycle (Start/Pause/Resume/Stop) into
JasperFx.Events.Daemon.ProjectionCoordinatorBase. Reduce Marten's coordinator to
a subclass:

- Supply via the base ctor: BuildDistributor(store), the store's
  ResiliencePipeline, Events.TimeProvider, and the three settings
  (LeadershipPollingTime as a TimeSpan, AgentPauseTime, HealthCheckPollingTime).
- Implement the seams: ResolveDaemon (keeps Marten's ImHashMap +
  double-checked-lock daemon cache) and ResolvedDaemons; keep the existing
  DaemonForMainDatabase / DaemonForDatabase / AllDaemonsAsync.
- Delete the lifted-into-base members: executeAsync, start/stopAgentsIfNecessary,
  tryStartAgent, the Start/Pause/Resume/Stop bodies, pauseDistributor, and the
  DaemonShardName record. Behavior is unchanged (the base adopted Marten's
  resilient agent-start + single-cancellation lifecycle verbatim).

DaemonTests 185/0; HotCold leadership-election tests (detect_high_water_mark,
end_to_end_with_events_already_published) pass.

Closes #4516.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Completes #4527 (the serialization-enum subset landed in #4529). weasel#287
lifted the dialect-agnostic Hi-Lo pieces into Weasel.Core.Sequences:
HiloSequenceBase (state + arithmetic), ISequence, IReadOnlyHiloSettings,
HiloSettings, and HiloSequenceAdvanceToNextHiAttemptsExceededException.

- Marten's HiloSequence now derives from HiloSequenceBase, keeping only the
  PostgreSQL I/O (mt_get_next_hi stored function in AdvanceToNextHi/Sync, the
  mt_hilo floor update in SetFloor). The client-side arithmetic
  (AdvanceValue/ShouldAdvanceHi/NextInt/NextLong/TrySetCurrentHi/hi-lo state) is
  inherited verbatim — id allocation is unchanged.
- Delete Marten's ISequence / IReadOnlyHiloSettings / HiloSettings /
  HiloSequenceAdvanceToNextHiAttemptsExceededException copies and alias the old
  names via the shared dedupe file (shapes identical; the exception's base
  changed MartenException -> Exception but nothing catches it as MartenException).
- AdvanceToNextHiSync is protected on the base; the one test that drove it
  directly now invokes it reflectively to keep exercising the sync I/O path.

Hi-Lo + sequence-id tests pass (32/0).

Closes #4527.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit d57687a into master May 20, 2026
6 checks passed
@jeremydmiller jeremydmiller deleted the feat/dedupe-heavy-refactors-coordinator-hilo-versioning branch May 20, 2026 16:16
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.

Reduce ProjectionCoordinator to a ProjectionCoordinatorBase subclass (consume jasperfx#326)

1 participant