Recipes

Shape input with Throttle

Choose leading, trailing, or leading-and-trailing admission for a keyed command stream.

v0.1.0-dev.2Intermediateusecase_forge
Open source reference

Shape input with Throttle

Throttle controls how often related Commands leave admission. It does not limit how many already admitted Executions may run.

Choose the mode

ModeFirst CommandLatest Command during windowUse when
leadingadmitted immediatelyrejectedimmediate response matters
trailingretained until the window endsreplaces the retained candidateonly the latest value matters
leadingAndTrailingadmitted immediatelylatest is retained for the endimmediate and final values both matter
dart
registerCommand<RefreshMetrics>(
  _refresh,
  instructions: UseCaseInstructionOverrides(
    input: UseCaseInputInstructionOverrides(
      throttle: UseCaseThrottleInstructions(
        duration: const Duration(seconds: 1),
        mode: UseCaseThrottleMode.leadingAndTrailing,
      ),
    ),
  ),
);

RefreshMetrics.executionKey must identify the dashboard or resource whose refreshes belong to one lane. Commands with another exact type or key use independent windows.

Observe rejection explicitly

Intermediate Commands are reported to onCommandRejected as throttled; they never become terminal history entries. If every intent must eventually execute, throttle is the wrong Instruction—use sequential processing instead.

ARKTELOS

Purpose-built engineering systems for software that has to hold.