Skip to content

[Context]: add progress and cancellation (fail-fast) to batch primitives #23

Description

@rian-be

Summary

Add progress + cancellation support to the batch primitives.

Motivation

Batch operations need to report rich progress and abort not only on request but also fail-fast when a non-TryEach delegate throws.

Scope

2.7.1 Cancellation — Fail-Fast

  • If a non-TryEach delegate throws, the library signals cancellation to the remaining tasks via an internal CancellationTokenSource, preventing wasted work whose results will be discarded.
  • External CancellationToken from the caller is honored.

2.7.2 Progress reporting

  • IProgress<T> integration returning a rich ExecutionProgress, not just 0-100%:
public record ExecutionProgress(
    int CompletedCount,
    int TotalCount,
    int FailedCount,
    TimeSpan ElapsedTime
);
  • ExecutionProgress record.
  • Fail-fast CancellationTokenSource cascade on first error (non-TryEach).
  • Caller-supplied CancellationToken honored throughout.
  • Progress throttled/reported via IProgress<T>.
  • Unit tests: fail-fast aborts siblings; external cancel aborts all.

Design Expectations

  • Progress is rich, not a bare percentage.
  • Fail-fast only applies to throw-style (non-TryEach) execution.
  • Composes with concurrency/map primitives.

Acceptance Criteria

  • On first throw, remaining tasks receive cancellation.
  • Reported progress reflects completed/failed/total/elapsed.
  • Caller CancellationToken stops the batch promptly.

Non-Goals

  • No retry policy (Polly adapter).
  • No partial-success aggregation (TryEach covers single failures without aborting the whole).

Activity

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