effect_core library
Lazy typed effects, scoped resources and structured asynchronous concurrency.
Classes
-
BoundedQueue<
A> - FIFO bounded channel; capacity zero rendezvous is supported. Shutdown drops buffered items and wakes both producers and consumers. No graceful end alias.
- CancellationToken
- An idempotent cooperative signal. It cannot stop CPU loops or arbitrary I/O.
-
Cause<
E> - Expected errors, stack-traced defects, interruption, or ordered combinations.
- CircuitBreaker
- Single-isolate circuit breaker. Only selected expected errors count. A single probe is admitted after cooldown; cancellation releases the probe.
- Clock
- Injectable time source; sleep must stop waiting when its token is cancelled.
- Context
- Immutable heterogeneous services. Context requirements are checked at run time; use an aggregate environment for static dependency evidence.
-
Defect<
E> -
Deferred<
A, E> - Exactly one memoized outcome, shared by independent interruptible waiters.
-
Effect<
A, E, R> -
Lazy reusable computation.
Eshould be a shared sealed error family.Rdescribes its environment; Dart covariance allows widening R, so it is not complete static provision evidence. Incorrect widened provision defects. Ordinary map/flatMap/defer chains use a stack-safe instruction interpreter. -
EffectStream<
A, E, R> - Pull-based effects with a local scope per consumption. No implicit buffers.
-
Exit<
A, E> - The observable outcome after a fiber's children and resources are cleaned up.
-
Expected<
E> -
Failure<
A, E> -
Fiber<
A, E> - A running same-isolate computation. Awaiting its Exit includes cleanup.
-
FiberContext<
R> - Extension boundary for services and adapters. Custom waits must cooperate with token, or evaluate Effect.fromFuture to gain interruption handling.
-
Interrupted<
E> -
Layer<
E> - A graph node memoized by identity within the enclosing scope.
- LifecycleEvent
- Immutable runtime events; sinks must avoid blocking. Sink exceptions are isolated from effect outcomes. Events contain no environment or error values.
- LogRecord
- MonotonicClock
- Optional monotonic capability. Legacy custom Clocks remain source compatible.
-
PubSub<
A> - Atomic bounded fan-out to current subscribers. Slow subscribers backpressure publishers; new subscribers receive future publications only (no replay).
-
Pull<
A> - QueueClosed
- Shutdown is an expected channel error, separate from interruption/defects.
- QueueFull
- Finite pending admission was exhausted; the channel remains open.
- RateLimiter
- Spaces admissions with the injected clock. A cancelled reservation leaves an unused slot, preventing bursts. No tasks or timers are retained by helper.
- RealClock
-
Ref<
A> - Atomic synchronous state in one isolate. Mutators run lazily, once per run.
-
Runtime<
R> - Supplies an environment, clock and logger, and owns all externally forked roots. Shutdown rejects new roots and awaits existing roots' cleanup.
- RuntimeMetrics
- Bounded aggregate metrics, with no per-fiber history retained.
- Schedule
- Finite policy: recurrences counts additional executions, not the first.
- Scope
- Finalizers run once in reverse registration order, after scoped children.
- Semaphore
- Strict FIFO weighted permits. Larger head requests cannot be bypassed.
-
Sequential<
E> -
ServiceKey<
A> - An identity-based key. Equal names do not alias services.
-
Sink<
A, B, E, R> - Reusable sink; each consumption allocates fresh state. False stops upstream.
-
StreamEnd<
A> -
StreamValue<
A> -
Subscription<
A> - A subscription belongs to its creation scope, or must be closed manually if created through subscribeUnsafe. Closing never shuts down other subscribers.
-
Success<
A, E> -
SynchronizedRef<
A> - Effectful atomic modification, serialized across asynchronous callbacks.
- TestClock
- Manual time, with no wall-clock delays. Advance after sleepers register.
- Unit
- The environment of an effect with all dependencies supplied.
Enums
- CircuitState
- A snapshot of a circuit's admission state.
Extensions
-
CauseDiagnostics
on Cause<
E> -
EffectPolicy
on Effect<
A, E, R> -
ScopedAcquisition
on Effect<
A, E, R>
Functions
-
elapsedTime(
Clock clock) → Duration - Duration policies use monotonic time where available. A legacy custom Clock falls back to its injected wall time, retaining existing test behavior.
-
log<
E, R> (String message, {String level = 'info', Map< String, Object?> fields = const {}}) → Effect<Unit, E, R> - Emit an immutable structured log through the runtime's injected sink.
-
mapCause<
A, B> (Cause< A> cause, B expected(A)) → Cause<B> - Stack-safe, ordered transformation of expected errors, preserving cause shape.
-
restoreCause<
E> (Cause< Object?> cause) → Cause<E> - Retype at an erased extension boundary without dropping valid diagnostics.
Typedefs
- LifecycleSink = void Function(LifecycleEvent event)
- LogSink = void Function(LogRecord)