Add Effect.FlushlessCreateNextChild for appending numbered child effects#186
Merged
Conversation
Introduces a flushless primitive that finds the next free direct-child slot under a given parent EffectId (highest existing child index + 1) and records the provided content there as a completed effect, returning the new child's EffectId. Index-selection and reservation happen under a single lock so concurrent callers cannot collide on the same index. Generalizes the hand-rolled next-child bookkeeping in IdempotencyKeys.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a flushless
Effect.FlushlessCreateNextChild<T>primitive that, for a given parentEffectId, finds the next free direct-child slot and records the provided content there as a completed effect.EffectId.Get/TryGet) and the next call already sees the reserved slot, so flushing is not needed for index correctness — durability is the caller's concern (callEffect.Flush()), matching the existingFlushless*family._syncacquisition (via an extracted lock-freeAddToPendingCore) so concurrent callers cannot collide on the same index.This generalizes the hand-rolled next-child bookkeeping currently in
Queuing/IdempotencyKeys.cs. MigratingIdempotencyKeysonto this primitive is intentionally left as a follow-up.Caveat
This is a raw append: each call adds a new child, so it is not replay-idempotent on its own. It is intended for callers driven by genuinely-new external events (as
IdempotencyKeysis, guarded by its own content dedup).Tests
CreateNextChildTests(4 tests, in-memory):0Clear)