Skip to main content

stream_task

Attribute Macro stream_task 

Source
#[stream_task]
Expand description

Apply to the StreamTask trait definition, an impl StreamTask<S [, K]> for T block, or an inherent impl T { ... } block.

Use as #[cano::task::stream]. StreamTask is a genuine stream-processing model: consume an impl Stream continuously, flush per [StreamWindow] window, run until the workflow’s CancellationToken fires, and persist a resumable cursor (via [Workflow::register_stream]). Per-item errors are governed by [StreamErrorPolicy].

Two surface forms on impl blocks:

  1. Trait-impl form: #[task::stream] impl StreamTask<S> for T { type Item = ..; .. }.
  2. Inherent-impl form: #[task::stream(state = S [, key = K])] impl T { async fn open(..) .. } — the macro infers type Item from process_item’s owned item parameter and type Output / type Cursor from the Ok 2-tuple of process_item’s return, requires open / process_item / flush_window / on_close, and emits a companion impl Task<S [, K]> for T whose run forwards to StreamTask::run_in_memory.

On a trait definition the macro just performs the async-fn-in-trait rewrite.

The default config() injected by the inherent form is [TaskConfig::minimal()] (no outer retry — like PollTask; an outer retry would re-invoke open()).