State<_A, E>Represents the state of a transactional queue with sophisticated lifecycle management.
Details
The queue progresses through three states:
- Open: Accepting offers and serving takes normally
- Closing: No new offers accepted, serving remaining items until empty
- Done: Terminal state with completion cause, no further operations possible
Example (Inspecting queue lifecycle states)
import type { TxQueue } from "effect"
// State progression example
declare const state: TxQueue.State<string, Error>
if (state._tag === "Open") {
console.log("Queue is accepting new items")
} else if (state._tag === "Closing") {
console.log("Queue is draining, cause:", state.cause)
} else {
console.log("Queue is done, cause:", state.cause)
}models
Source effect/TxQueue.ts:5712 lines
export type type State<_A, E> =
| {
readonly _tag: "Open"
}
| {
readonly _tag: "Closing"
readonly cause: Cause.Cause<E>
}
| {
readonly _tag: "Done"
readonly cause: Cause.Cause<E>
}
Represents the state of a transactional queue with sophisticated lifecycle management.
Details
The queue progresses through three states:
- Open: Accepting offers and serving takes normally
- Closing: No new offers accepted, serving remaining items until empty
- Done: Terminal state with completion cause, no further operations possible
Example (Inspecting queue lifecycle states)
import type { TxQueue } from "effect"
// State progression example
declare const state: TxQueue.State<string, Error>
if (state._tag === "Open") {
console.log("Queue is accepting new items")
} else if (state._tag === "Closing") {
console.log("Queue is draining, cause:", state.cause)
} else {
console.log("Queue is done, cause:", state.cause)
}
State<function (type parameter) _A in type State<_A, E>_A, function (type parameter) E in type State<_A, E>E> =
| {
readonly _tag: "Open"_tag: "Open"
}
| {
readonly _tag: "Closing"_tag: "Closing"
readonly cause: Cause.Cause<E>(property) 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.type Cause.Cause = /*unresolved*/ anyCause<function (type parameter) E in type State<_A, E>E>
}
| {
readonly _tag: "Done"_tag: "Done"
readonly cause: Cause.Cause<E>(property) 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.type Cause.Cause = /*unresolved*/ anyCause<function (type parameter) E in type State<_A, E>E>
}Referenced by 8 symbols