Skip to content

Register Lazy<T> for ancillary stores in projections#4251

Merged
jeremydmiller merged 3 commits intomasterfrom
ancillary-stores-projections
Apr 14, 2026
Merged

Register Lazy<T> for ancillary stores in projections#4251
jeremydmiller merged 3 commits intomasterfrom
ancillary-stores-projections

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Summary

Closes #4244, closes #4226

  • AddMartenStore<T>() now automatically registers Lazy<T> as a singleton in the DI container
  • This enables safe injection of ancillary store references into projections without the startup deadlock caused by direct constructor injection
  • Added documentation page explaining the problem, the Lazy<T> solution, and cross-store enrichment patterns
  • Added tests verifying the Lazy<T> service registration

Test plan

  • lazy_of_ancillary_store_is_registered_as_singleton — verifies Lazy<T> resolves and returns the same instance as direct resolution
  • lazy_of_ancillary_store_can_be_injected_into_a_service — verifies constructor injection of Lazy<T> works

🤖 Generated with Claude Code

jeremydmiller and others added 3 commits April 14, 2026 17:04
Documents the known deadlock issue when constructor-injecting ancillary
stores into projections, the Func<T> workaround, and the planned
IHasDependencies interface that will provide a clean solution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tion pattern (#4244, #4226)

AddMartenStore<T>() now automatically registers Lazy<T> as a singleton,
enabling safe injection of ancillary store references into projections
without the startup deadlock caused by direct constructor injection.
Includes tests and documentation showing the Lazy<T> pattern for
cross-store enrichment scenarios.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Bug_4246 test from PR #4248 sets the sequence above int32 max but
didn't enable EnableBigIntEvents, causing the mt_quick_append_events
function to overflow with its default int types.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit 51f3d43 into master Apr 14, 2026
5 of 6 checks passed
@jeremydmiller jeremydmiller deleted the ancillary-stores-projections branch April 14, 2026 23:06
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.

Code generation freezes when injecting Ancillary Marten Stores into projections Support Ancillary Marten Stores in Event Enrichment

1 participant