Skip to content

feat: CommandBatch type and SendBatchAsync() for batched command execution#421

Merged
samtrion merged 1 commit intomainfrom
copilot/add-command-batch-and-send-batch-async
Apr 19, 2026
Merged

feat: CommandBatch type and SendBatchAsync() for batched command execution#421
samtrion merged 1 commit intomainfrom
copilot/add-command-batch-and-send-batch-async

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

Adds sequential batch command execution to IMediatorSendOnly — execute a list of void commands in order, stopping and propagating the first exception with no rollback.

New Types

  • CommandBatch (Extensibility/CommandBatch.cs) — fluent builder that stores commands as type-erased Func<IMediatorSendOnly, CancellationToken, Task> delegates
  • MediatorSendOnlyExtensions (Extensibility/MediatorSendOnlyExtensions.cs) — SendBatchAsync extension on IMediatorSendOnly

Usage

var batch = new CommandBatch()
    .Add(new CreateOrderCommand(items))
    .Add(new ReserveInventoryCommand(items))
    .Add(new SendConfirmationCommand(customerId));

await mediator.SendBatchAsync(batch, cancellationToken);
// On first failure: exception propagates, remaining commands skipped, no rollback

Key Design Decisions

  • Add<TCommand> constrained to ICommand (void) — batch returns Task, responses are meaningless
  • Commands stored as closed-over delegates at Add time, not re-resolved at execution time
  • Commands list is internal to keep the execution contract encapsulated in SendBatchAsync

Copilot AI linked an issue Apr 17, 2026 that may be closed by this pull request
7 tasks
Copilot AI changed the title [WIP] Add CommandBatch type and SendBatchAsync for batched execution feat: CommandBatch type and SendBatchAsync() for batched command execution Apr 17, 2026
Copilot AI requested a review from samtrion April 17, 2026 16:38
@samtrion samtrion marked this pull request as ready for review April 18, 2026 10:52
@samtrion samtrion requested a review from a team as a code owner April 18, 2026 10:52
@samtrion samtrion force-pushed the copilot/add-command-batch-and-send-batch-async branch from 7f3086c to 5f63702 Compare April 18, 2026 10:52
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.28%. Comparing base (ccdff8a) to head (5f63702).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #421      +/-   ##
==========================================
+ Coverage   91.85%   92.28%   +0.42%     
==========================================
  Files         146      148       +2     
  Lines        5547     5558      +11     
  Branches      522      523       +1     
==========================================
+ Hits         5095     5129      +34     
+ Misses        304      280      -24     
- Partials      148      149       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samtrion samtrion merged commit 890cdb6 into main Apr 19, 2026
11 checks passed
@samtrion samtrion deleted the copilot/add-command-batch-and-send-batch-async branch April 19, 2026 19:31
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.

feat: CommandBatch type and SendBatchAsync() for batched command execution

2 participants