Skip to content

[Context]: add TryEachInContextAsync best-effort batch #19

Description

@rian-be

Summary

Add TryEachInContextAsync — a best-effort batch runner that continues processing remaining items when individual ones fail, collecting errors instead of aborting the whole batch.

Goal

Support partial success: keep 995 of 1000 emails when 5 fail, reporting failures at the end rather than halting.

Problem

ExecuteAll/Map propagates the first exception and abandons the rest. For bulk writes/notifications, a single bad address should not discard the remaining legitimate items.

Scope

  • TryEachInContextAsync returning a result object.
  • result record: SuccessCount, FailureCount, HasErrors, Failures ({Item, Exception}).
  • Each item runs in a context snapshot; exceptions per item are caught and collected.
  • Optional CancellationToken to abort between items.
  • Unit tests: mixed success/failure scenarios.

Design Expectations

  • Per-item isolation and events identical to base execution.
  • Failures are structural (exception) not state-corrupting.
  • Pairs naturally with MapParallel for bounded best-effort batches.

Acceptance Criteria

  • Returns counts and failure list instead of throwing on first item.
  • Does not corrupt context across items.
  • Respects cancellation between items.

Non-Goals

  • No retry (resilience lives in the Polly adapter).
  • No ordering guarantee (see Ordered/Unordered).
  • No automatic partial-failure rollback.

Activity

  1. added
    enhancementNew feature or request
    extensionExtension behaviors / helpers
    concurrencyParallel / batch / async execution
    on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    concurrencyParallel / batch / async executionenhancementNew feature or requestextensionExtension behaviors / helpers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions