The durable store port. All operations are backend-agnostic; a backend (SQLite, …) provides the concrete implementation.
export interface DurableQueueStoreShape {
/**
* Persist a pending entry. Dedups on `dedupKey` among live entries (`inserted` vs
* `deduplicated`); if a live entry with that key exists at a *lower* priority, raises it
* (`escalated`).
*/
readonly DurableQueueStoreShape.offer: (entry: DurableEntryInput) => Effect.Effect<OfferResult, DurableQueueError>Persist a pending entry. Dedups on dedupKey among live entries (inserted vs
deduplicated); if a live entry with that key exists at a lower priority, raises it
(escalated).
offer: (
entry: DurableEntryInput(parameter) entry: {
id: string;
key: string;
dedupKey: string;
priority: DurablePriority;
payload: unknown;
schemaVersion: number;
}
entry: DurableEntryInput,
) => 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 OfferResult =
| "inserted"
| "escalated"
| "deduplicated"
Outcome of
DurableQueueStoreShape.offer
.
OfferResult, class DurableQueueErrorclass DurableQueueError {
name: string;
message: string;
stack: string;
cause: unknown;
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;
_tag: Tag;
operation: string;
}
A backend failure (wraps the underlying driver error).
DurableQueueError>;
/**
* Atomically lease the top-priority available entry (FIFO within a priority), bumping
* `attempts` and setting a lease (`leaseMillis`). `None` if nothing is available.
*/
readonly DurableQueueStoreShape.take: (options: { readonly key: string; readonly leaseMillis: number }) => Effect.Effect<Option.Option<DurableEntry>, DurableQueueError>Atomically lease the top-priority available entry (FIFO within a priority), bumping
attempts and setting a lease (leaseMillis). None if nothing is available.
take: (options: {
readonly key: string
readonly leaseMillis: number
}
options: {
readonly key: stringkey: string;
readonly leaseMillis: numberleaseMillis: number;
}) => 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<import OptionOption.type Option<A> = Option.None<A> | Option.Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<DurableEntry>, class DurableQueueErrorclass DurableQueueError {
name: string;
message: string;
stack: string;
cause: unknown;
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;
_tag: Tag;
operation: string;
}
A backend failure (wraps the underlying driver error).
DurableQueueError>;
/** Acknowledge success — remove the entry. */
readonly DurableQueueStoreShape.complete: (id: string) => Effect.Effect<void, DurableQueueError>Acknowledge success — remove the entry.
complete: (id: stringid: string) => 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<void, class DurableQueueErrorclass DurableQueueError {
name: string;
message: string;
stack: string;
cause: unknown;
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;
_tag: Tag;
operation: string;
}
A backend failure (wraps the underlying driver error).
DurableQueueError>;
/**
* Negative-ack — requeue (clear the lease) for retry, or dead-letter once `attempts` reaches
* `maxAttempts`.
*/
readonly DurableQueueStoreShape.fail: (id: string, options: { readonly maxAttempts: number }) => Effect.Effect<FailResult, DurableQueueError>Negative-ack — requeue (clear the lease) for retry, or dead-letter once attempts reaches
maxAttempts.
fail: (
id: stringid: string,
options: {
readonly maxAttempts: number
}
options: { readonly maxAttempts: numbermaxAttempts: number },
) => 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 FailResult =
| "requeued"
| "deadLettered"
Outcome of
DurableQueueStoreShape.fail
.
FailResult, class DurableQueueErrorclass DurableQueueError {
name: string;
message: string;
stack: string;
cause: unknown;
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;
_tag: Tag;
operation: string;
}
A backend failure (wraps the underlying driver error).
DurableQueueError>;
/** Pending counts per priority (in-flight included). */
readonly DurableQueueStoreShape.sizes: (key: string) => Effect.Effect<DurableSizes, DurableQueueError>Pending counts per priority (in-flight included).
sizes: (
key: stringkey: string,
) => 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<DurableSizes, class DurableQueueErrorclass DurableQueueError {
name: string;
message: string;
stack: string;
cause: unknown;
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;
_tag: Tag;
operation: string;
}
A backend failure (wraps the underlying driver error).
DurableQueueError>;
/**
* Reclaim work whose lease has expired (`locked_until < now`) — the at-least-once recovery used
* on boot/restart. Returns the count reclaimed.
*/
readonly DurableQueueStoreShape.recover: (key: string) => Effect.Effect<number, DurableQueueError>Reclaim work whose lease has expired (locked_until < now) — the at-least-once recovery used
on boot/restart. Returns the count reclaimed.
recover: (key: stringkey: string) => 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<number, class DurableQueueErrorclass DurableQueueError {
name: string;
message: string;
stack: string;
cause: unknown;
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;
_tag: Tag;
operation: string;
}
A backend failure (wraps the underlying driver error).
DurableQueueError>;
/** Delete all pending (incl. in-flight) entries for a queue. Returns the count removed. */
readonly DurableQueueStoreShape.clear: (key: string) => Effect.Effect<number, DurableQueueError>Delete all pending (incl. in-flight) entries for a queue. Returns the count removed.
clear: (key: stringkey: string) => 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<number, class DurableQueueErrorclass DurableQueueError {
name: string;
message: string;
stack: string;
cause: unknown;
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;
_tag: Tag;
operation: string;
}
A backend failure (wraps the underlying driver error).
DurableQueueError>;
/**
* Remove and return **available** (not in-flight) backlog entries matching `id` or `key` (all if
* neither given). Powers the durable `release` / `deadLetter` / `drop` control verbs. In-flight
* (leased) work is left untouched — it can't be selector-targeted while a worker holds it.
*/
readonly DurableQueueStoreShape.drain: (key: string, match: { readonly id?: string; readonly key?: string }) => Effect.Effect<ReadonlyArray<DurableEntry>, DurableQueueError>Remove and return available (not in-flight) backlog entries matching id or key (all if
neither given). Powers the durable release / deadLetter / drop control verbs. In-flight
(leased) work is left untouched — it can't be selector-targeted while a worker holds it.
drain: (
key: stringkey: string,
match: {
readonly id?: string
readonly key?: string
}
match: { readonly id?: string | undefinedid?: string; readonly key?: string | undefinedkey?: string },
) => 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<interface ReadonlyArray<T>ReadonlyArray<DurableEntry>, class DurableQueueErrorclass DurableQueueError {
name: string;
message: string;
stack: string;
cause: unknown;
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;
_tag: Tag;
operation: string;
}
A backend failure (wraps the underlying driver error).
DurableQueueError>;
}