Skip to content

Convert EditFailedMessageManager to an atomic write operation - #5763

Open
rbev wants to merge 3 commits into
masterfrom
rhys/atomic-commit2
Open

Convert EditFailedMessageManager to an atomic write operation#5763
rbev wants to merge 3 commits into
masterfrom
rhys/atomic-commit2

Conversation

@rbev

@rbev rbev commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

This pull request refactors and simplifies the "edit failed message" workflow in both EF Core and RavenDB persistence implementations. It removes the manager/session-based pattern in favor of explicit, atomic data store operations, clarifies persistence guidelines, and updates tests to match the new approach. The result is clearer, more robust, and easier-to-maintain persistence APIs for editing failed messages.

Persistence API refactoring and simplification:

  • Replaces the EditFailedMessagesManager and session-based workflow in both EF Core and RavenDB with direct, atomic methods (TryBeginEdit, GetCurrentEditingRequestId) on the data store classes, eliminating the need for manager objects and implicit state. [1] [2] [3] [4]

Concurrency and atomicity improvements:

  • Ensures that edit-acquisition operations are atomic and handle concurrency conflicts explicitly, with provider-specific exception handling and clear domain outcomes (e.g., reporting if another edit has already been acquired). [1] [2]

Documentation updates:

  • Adds new guidelines to the coding and design documentation, recommending explicit persistence operations over generic session managers and describing best practices for atomic operations and unit-of-work APIs.

Test updates and coverage:

  • Refactors and renames tests to match the new API, ensuring that timestamping and edit-acquisition logic are properly validated for both EF Core and RavenDB, and adds new tests for RavenDB expiration behavior. [1] [2] [3] [4]

Code cleanup:

  • Removes obsolete manager/session classes and related abstractions that are no longer needed after the refactor. [1] [2]

@rbev
rbev marked this pull request as ready for review August 13, 2026 08:23
@rbev
rbev force-pushed the rhys/atomic-commit2 branch from a9afb92 to 84f4f60 Compare August 13, 2026 08:23
/// <param name="Outcome">The acquisition outcome.</param>
/// <param name="FailedMessage">The snapshot used to dispatch an acquired or idempotently reacquired edit.</param>
/// <param name="ExistingEditId">The existing claim for an idempotent retry or competing edit.</param>
public sealed record BeginEditResult(BeginEditOutcome Outcome, FailedMessage? FailedMessage = null, string? ExistingEditId = null);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so much nicer

@rbev
rbev force-pushed the rhys/atomic-commit2 branch from 84f4f60 to 581ce57 Compare August 14, 2026 01:51
@rbev
rbev force-pushed the rhys/atomic-commit2 branch from 581ce57 to 8549437 Compare August 14, 2026 03:21
@rbev
rbev force-pushed the rhys/atomic-commit2 branch from 8549437 to dd73e29 Compare August 14, 2026 03:51
@rbev
rbev force-pushed the rhys/atomic-commit2 branch from dd73e29 to 28eb20d Compare August 14, 2026 05:09
Base automatically changed from rhys/atomic-commit to master August 14, 2026 05:26
@rbev
rbev force-pushed the rhys/atomic-commit2 branch from 28eb20d to 1a50a93 Compare August 14, 2026 05:26
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.

2 participants