feat: CommandHandler auto-retry on concurrency conflict #156

Closed
opened 2026-03-01 12:31:09 +00:00 by ash · 0 comments
Owner

Problem

When Append returns ErrConcurrencyConflict, the CommandHandler returns the error to the caller. If the caller doesnt retry (common mistake), the command is silently dropped.

Solution

Add configurable auto-retry:

eskit.NewCommandHandler(store, decider,
    eskit.WithConflictRetry(3),              // retry up to 3 times
    eskit.WithConflictRetryDelay(10*time.Millisecond),
)

On conflict: reload events, re-evolve state, re-decide, re-append. Exponential backoff between retries.

This is the standard pattern in event sourcing — the framework should handle it, not every caller.

Priority

High — footgun for every user who forgets to handle ErrConcurrencyConflict

## Problem When Append returns ErrConcurrencyConflict, the CommandHandler returns the error to the caller. If the caller doesnt retry (common mistake), the command is silently dropped. ## Solution Add configurable auto-retry: ```go eskit.NewCommandHandler(store, decider, eskit.WithConflictRetry(3), // retry up to 3 times eskit.WithConflictRetryDelay(10*time.Millisecond), ) ``` On conflict: reload events, re-evolve state, re-decide, re-append. Exponential backoff between retries. This is the standard pattern in event sourcing — the framework should handle it, not every caller. ## Priority High — footgun for every user who forgets to handle ErrConcurrencyConflict
ash closed this issue 2026-03-01 12:40:07 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ash/eskit#156
No description provided.