Return result instead of exception#2
Open
mostlyobvious wants to merge 10 commits into
Open
Conversation
Owner
mostlyobvious
commented
May 26, 2026
- result carries position of last appended (success) or last seen event (failure due to matching fail_if), which greatly helps in retries and continued appends without additional query
- serialization error surfaces only after certain threshold, adjustable to concurrency
- Replace append-condition exceptions with explicit success and failure result values so callers can branch without relying on control flow. - Return append status from the SQL append function to distinguish normal condition failures from serialization failures. - Retry serialization failures in the repository and raise a library-level error only after retry exhaustion. - Update adapter contracts, benchmarks, documentation, and tests for the new append result API.
- Use a domain-specific error name that describes the actual failure: append retries were exhausted after serialization conflicts.
- Make append serialization retries configurable so applications can tune contention handling for their workload. - Raise the default retry count to 9 to allow ten total attempts before surfacing an append-retries-exhausted error.
- Include the last appended event position in successful append results so callers can continue from the write boundary without issuing a read. - Return the position from the SQL append result alongside the status to keep the Ruby result derived from the database write. - Preserve nil for successful empty appends because no event position is created in that case.
- Return a successful append result without opening a transaction when there are no events to write. - Avoid invoking append-condition checks for empty writes because no database state can change.
- Include the last matching fail-if event position in failure results so callers can refresh their read boundary after a conditional append loses. - Derive the position in the append SQL function so the reported boundary is consistent with the append-condition check.
- Use the failure result position when retrying conditional append benchmark writes so retries do not need a follow-up read to find the new boundary. - Keep benchmark contention behavior aligned with the public append result API.
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.