(entry: QueueEntry<T>, cause: Cause.Cause<E>): Effect.Effect<
QueueFailureDisposition,
never,
R
>Optional inline failure hook — the one legitimate control callback (a stream is after-the-fact
and can't decide disposition). Runs in the worker R on each failed item, returning a
QueueFailureDisposition. Observation still belongs on the events stream; this is
control.
export interface interface QueueOnFailure<T, E, R>Optional inline failure hook — the one legitimate control callback (a stream is after-the-fact
and can't decide disposition). Runs in the worker R on each failed item, returning a
QueueFailureDisposition
. Observation still belongs on the events stream; this is
control.
QueueOnFailure<function (type parameter) T in QueueOnFailure<T, E, R>T, function (type parameter) E in QueueOnFailure<T, E, R>E, function (type parameter) R in QueueOnFailure<T, E, R>R> {
(
entry: QueueEntry<T>(parameter) entry: {
item: T;
entryId: string;
key: string;
priority: Priority;
level: number;
attempts: number;
timestamps: QueueEntryTimestamps;
batchId: string;
releaseId: string;
sourceHyperlinkId: string;
attributes: { readonly [key: string]: unknown };
}
entry: interface QueueEntry<T>QueueEntry<function (type parameter) T in QueueOnFailure<T, E, R>T>,
cause: Cause.Cause<E>(parameter) cause: {
reasons: ReadonlyArray<Reason<E>>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
cause: import CauseCause.interface Cause<out E>A structured representation of how an Effect failed.
When to use
Use to preserve the full structured failure information for an effect instead
of collapsing it to a single error value.
Details
Access the individual failure entries through the reasons array, then
narrow each entry with
isFailReason
,
isDieReason
, or
isInterruptReason
.
- Use
hasFails
/
hasDies
/
hasInterrupts
to test
for the presence of specific reason kinds without iterating.
- Use
findError
/
findDefect
to extract the first value
of a given kind.
- Use
combine
to merge two causes.
Cause implements Equal — two causes with the same reasons (by value)
compare as equal.
Example (Creating and inspecting a cause)
import { Cause } from "effect"
const cause = Cause.fail("Something went wrong")
console.log(cause.reasons.length) // 1
console.log(Cause.isFailReason(cause.reasons[0])) // true
Companion namespace for the Cause interface.
Cause<function (type parameter) E in QueueOnFailure<T, E, R>E>,
): import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<type QueueFailureDisposition =
| "retry"
| "deadLetter"
| "drop"
| "default"
Per-error disposition returned by
QueueHyperlinkConfigWithoutItemSchema.onFailure
.
"retry" — re-enqueue the item at its own priority, honoring the attempts budget
(emits RetryScheduled, or RetryExhausted once the budget is spent).
"deadLetter" — emit a DeadLettered event; do not re-enqueue.
"drop" — emit a Dropped event; do not re-enqueue.
"default" — fall back to the queue's policy (auto re-enqueue when attempts is set,
otherwise log a warning).
QueueFailureDisposition, never, function (type parameter) R in QueueOnFailure<T, E, R>R>;
}