ChainContext class

Shared execution context for chain steps that provides metadata storage and execution control capabilities.

Key features:

  • Type-safe metadata storage
  • Execution timeout control
  • Chain abortion mechanism
  • Cross-step communication

Example:

final context = ChainContext(
  timeout: Duration(seconds: 30),
  initialMetadata: {'feature_enabled': true},
);

// Store and retrieve metadata
context.addMetadata('key', 'value');
final value = context.getMetadata<String>('key');

// Control execution
context.shouldAbort = true;

Constructors

ChainContext({Duration? timeout, Map<String, dynamic>? initialMetadata})
Shared execution context for chain steps that provides metadata storage and execution control capabilities.

Properties

hashCode int
The hash code for this object.
no setterinherited
keys Iterable<String>
Returns all metadata keys
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldAbort bool
Whether the chain execution should be aborted
getter/setter pair
startTime DateTime
Start time of the chain execution
final
timeout Duration?
Optional timeout for the entire chain execution
final

Methods

addMetadata(String key, dynamic value) → void
Adds metadata that can be accessed by subsequent steps
clearMetadata() → void
Clears all metadata
getMetadata<T>(String key) → T?
Retrieves metadata of specific type T
hasMetadata(String key) bool
Returns true if context contains metadata with given key
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeMetadata(String key) bool
Removes metadata by key
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited