Effect MQ API
Generated public TypeScript reference for @relkit/effect-mq.
For configuration and examples, read schedules, docker, providers.
Public imports
@relkit/effect-mq— 7 exports@relkit/effect-mq/runtime— 22 exports@relkit/effect-mq/local-recipe— 1 exports@relkit/effect-mq/deployment— 4 exports
All exported APIs
Names link to their complete contracts. Re-exports share their original contract; legacy exports keep their separate identity. Examples link to the API’s inline sample, a maintained repository usage, or the shared module walkthrough.
build-catalog.ts
effectMqSdk
Signature
declare const effectMqSdk: "effect-mq@0.7.0";
effectVersion
Signature
declare const effectVersion: "4.0.1";
index.ts
EffectMqDeploymentProfile (interface)
Signature
export interface EffectMqDeploymentProfile {
readonly provider: "effect-mq";
readonly compatibility: "native";
readonly adapterId: "effect-mq";
readonly effect: typeof effectVersion;
readonly sdk: typeof effectMqSdk;
readonly database: "postgresql";
readonly durableSleep: false;
readonly workerRuntime: "bun";
readonly executionLimits: Readonly<{
readonly inputBytes: number;
readonly progressBytes: number;
readonly maxRunList: number;
}>;
readonly policyIdentity: readonly string[];
}
EffectMqWorkerPublication (interface)
Signature
export interface EffectMqWorkerPublication {
readonly provider: "effect-mq";
readonly mechanism: "effect-mq-sdk";
readonly taskId: string;
readonly taskVersion: string;
readonly buildId: string;
readonly serviceGeneration: string;
readonly entrypoint: string;
}
deploymentProfile
Signature
declare const deploymentProfile: EffectMqDeploymentProfile;
nativeWorkerPublication
Signature
declare const nativeWorkerPublication: (
value: Omit<EffectMqWorkerPublication, "provider" | "mechanism">,
) => EffectMqWorkerPublication;
index.ts
EffectMqAdapter (type alias)
Signature
type EffectMqAdapter<Options extends EffectMqOptions = EffectMqOptions> = ProviderAdapter<
typeof job,
"effect-mq",
ProviderConnectionValues,
ProviderBehavior<EffectMqBehavior>
>;
EffectMqBehavior (type alias)
Signature
type EffectMqBehavior = JobsServiceBehavior;
EffectMqOptions (interface)
Signature
export interface EffectMqOptions extends JobsServiceOptions {
readonly postgresUrl?: string | TextReference | SecretReference;
readonly schema?: string;
readonly tablePrefix?: string;
readonly queue?: string;
readonly native?: Readonly<Record<string, import("@relkit/contracts").JsonValue>>;
}
effectMq
Signature
declare const effectMq: <const Options extends EffectMqOptions = EffectMqOptions>(
options?: Options,
) => EffectMqAdapter<Options>;
effectMqConnectionContract
Signature
declare const effectMqConnectionContract: ProviderConnectionContract;
effectMqIntegration
Signature
declare const effectMqIntegration: IntegrationReference<"effect-mq">;
effectMqLocalRecipe
Signature
declare const effectMqLocalRecipe: ProviderLocalRecipeReference;
job.ts
EffectMqJobDefinition (interface)
Signature
export interface EffectMqJobDefinition {
readonly job: ReturnType<typeof Job.make>;
readonly workerLayer: ReturnType<typeof Worker.layer>;
readonly handlerLayer: unknown;
}
EffectMqJobOptions (interface)
Signature
export interface EffectMqJobOptions {
readonly name: string;
readonly queue?: string;
readonly attempts?: number;
readonly backoff?: {
readonly type: "fixed" | "exponential";
readonly delay: Duration.Input;
readonly factor?: number;
};
readonly handler: (
input: unknown,
signal: AbortSignal,
context: Worker.JobContext,
) => Promise<unknown>;
readonly worker?: Parameters<typeof Worker.layer>[0];
}
createEffectMqJob
Builds a schema-first native Job.make definition without exposing app schemas.
Signature
declare const createEffectMqJob: (options: EffectMqJobOptions) => EffectMqJobDefinition;
createEffectMqWorkerLayer
Signature
declare const createEffectMqWorkerLayer: (
options?: Parameters<typeof Worker.layer>[0],
) => ReturnType<typeof Worker.layer>;
index.ts
localRecipe
Signature
declare const localRecipe: Readonly<{
kind: "local-service-recipe";
protocolVersion: 2;
integrationId: "effect-mq";
recipeId: "effect-mq-docker";
recipeVersion: 2;
materializerId: "docker";
containers: ReadonlyArray<
Readonly<{
id: "postgres";
image: "postgres:16-alpine@sha256:cf78e76683b9ca8c5733cbbdce6c9262b45b6767934dd0a95e671f9a0fc20685";
ports: Readonly<{ postgres: 5432 }>;
volumes: ReadonlyArray<{ name: string; mountPath: string }>;
environment: Readonly<{
POSTGRES_DB: Readonly<{ value: "relkit" }>;
POSTGRES_USER: Readonly<{ value: "relkit" }>;
POSTGRES_PASSWORD: Readonly<{ secret: "postgresPassword" }>;
}>;
health: Readonly<{ command: Array<string>; intervalMs: 250; timeoutMs: 2000; retries: 60 }>;
networkAliases: ReadonlyArray<string>;
}>
>;
init: ReadonlyArray<
Readonly<{
id: "postgres-ready";
image: "postgres:16-alpine@sha256:cf78e76683b9ca8c5733cbbdce6c9262b45b6767934dd0a95e671f9a0fc20685";
dependsOn: ReadonlyArray<string>;
command: ReadonlyArray<string>;
environment: Readonly<{ POSTGRES_PASSWORD: Readonly<{ secret: "postgresPassword" }> }>;
}>
>;
workers: ReadonlyArray<
Readonly<{
id: "worker";
image: "oven/bun:1.3.10@sha256:b86c67b531d87b4db11470d9b2bd0c519b1976eee6fcd71634e73abfa6230d2e";
command: ReadonlyArray<string>;
dependsOn: ReadonlyArray<string>;
ports: Readonly<{ api: 3000 }>;
health: Readonly<{ command: Array<string>; intervalMs: 500; timeoutMs: 2000; retries: 120 }>;
networkAliases: ReadonlyArray<string>;
hostAliases: Readonly<{ "host.docker.internal": "host-gateway" }>;
environment: Readonly<{
POSTGRES_PASSWORD: Readonly<{ secret: "postgresPassword" }>;
RELKIT_EFFECT_MQ_MIGRATIONS: Readonly<{ value: "owned-by-jobs-service" }>;
}>;
}>
>;
volumes: Readonly<{
postgres: Readonly<{ mountPath: "/var/lib/postgresql/data"; persistent: true }>;
}>;
generatedSecrets: Readonly<{ postgresPassword: Readonly<{ bytes: 24; encoding: "hex" }> }>;
network: Readonly<{ internal: false }>;
ownership: Readonly<{ scope: "project"; retainVolumes: true }>;
outputs: ({
ports,
secrets,
}: LocalServiceRecipeOutputContext) => Readonly<{ postgresUrl: string }>;
}>;
local-support.ts
BUN_IMAGE
Signature
declare const BUN_IMAGE: "oven/bun:1.3.10@sha256:b86c67b531d87b4db11470d9b2bd0c519b1976eee6fcd71634e73abfa6230d2e";
POSTGRES_IMAGE
Signature
declare const POSTGRES_IMAGE: "postgres:16-alpine@sha256:cf78e76683b9ca8c5733cbbdce6c9262b45b6767934dd0a95e671f9a0fc20685";
number
Signature
declare const number: (value: unknown, name: string) => number;
text
Signature
declare const text: (value: unknown, name: string) => string;
local.ts
localRecipe
Signature
declare const localRecipe: Readonly<{
kind: "local-service-recipe";
protocolVersion: 2;
integrationId: "effect-mq";
recipeId: "effect-mq-docker";
recipeVersion: 2;
materializerId: "docker";
containers: ReadonlyArray<
Readonly<{
id: "postgres";
image: "postgres:16-alpine@sha256:cf78e76683b9ca8c5733cbbdce6c9262b45b6767934dd0a95e671f9a0fc20685";
ports: Readonly<{ postgres: 5432 }>;
volumes: ReadonlyArray<{ name: string; mountPath: string }>;
environment: Readonly<{
POSTGRES_DB: Readonly<{ value: "relkit" }>;
POSTGRES_USER: Readonly<{ value: "relkit" }>;
POSTGRES_PASSWORD: Readonly<{ secret: "postgresPassword" }>;
}>;
health: Readonly<{ command: Array<string>; intervalMs: 250; timeoutMs: 2000; retries: 60 }>;
networkAliases: ReadonlyArray<string>;
}>
>;
init: ReadonlyArray<
Readonly<{
id: "postgres-ready";
image: "postgres:16-alpine@sha256:cf78e76683b9ca8c5733cbbdce6c9262b45b6767934dd0a95e671f9a0fc20685";
dependsOn: ReadonlyArray<string>;
command: ReadonlyArray<string>;
environment: Readonly<{ POSTGRES_PASSWORD: Readonly<{ secret: "postgresPassword" }> }>;
}>
>;
workers: ReadonlyArray<
Readonly<{
id: "worker";
image: "oven/bun:1.3.10@sha256:b86c67b531d87b4db11470d9b2bd0c519b1976eee6fcd71634e73abfa6230d2e";
command: ReadonlyArray<string>;
dependsOn: ReadonlyArray<string>;
ports: Readonly<{ api: 3000 }>;
health: Readonly<{ command: Array<string>; intervalMs: 500; timeoutMs: 2000; retries: 120 }>;
networkAliases: ReadonlyArray<string>;
hostAliases: Readonly<{ "host.docker.internal": "host-gateway" }>;
environment: Readonly<{
POSTGRES_PASSWORD: Readonly<{ secret: "postgresPassword" }>;
RELKIT_EFFECT_MQ_MIGRATIONS: Readonly<{ value: "owned-by-jobs-service" }>;
}>;
}>
>;
volumes: Readonly<{
postgres: Readonly<{ mountPath: "/var/lib/postgresql/data"; persistent: true }>;
}>;
generatedSecrets: Readonly<{ postgresPassword: Readonly<{ bytes: 24; encoding: "hex" }> }>;
network: Readonly<{ internal: false }>;
ownership: Readonly<{ scope: "project"; retainVolumes: true }>;
outputs: ({
ports,
secrets,
}: LocalServiceRecipeOutputContext) => Readonly<{ postgresUrl: string }>;
}>;
postgres-listen.ts
postgres.ts
Builds lazy native PostgreSQL job-store Layers with scoped driver ownership and explicit timestamp compatibility.
EffectMqPostgresSchema
Signature
declare const EffectMqPostgresSchema: EffectMqPostgresSchema;
createEffectMqPostgresLayer
Builds the native PostgreSQL store Layer; the calling application owns schema migration and Layer lifetime.
Signature
declare const createEffectMqPostgresLayer: (
postgresUrl: string,
prefix?: string,
) => Layer.Layer<
JobStore.JobStore,
JobStore.JobStoreError | Layer.Error<ReturnType<typeof PgClient.layer>>
>;
createEffectMqPostgresSchema
Builds the existing native store’s complete schema without opening a database connection.
Signature
declare const createEffectMqPostgresSchema: (prefix?: string) => EffectMqPostgresSchema;
runEffectMq
Existing native Promise edge; callers supply and own the complete store/worker Layer lifetime.
Signature
declare const runEffectMq: <A, E>(
effect: Effect.Effect<A, E>,
options?: Effect.RunOptions | undefined,
) => Promise<A>;
postgres.types.ts
Describes the complete native Drizzle PostgreSQL schema used by the scoped effect-mq integration.
EffectMqPostgresSchema (interface)
Native table handles retain the SDK’s exact row, query and foreign-key contracts.
Signature
export interface EffectMqPostgresSchema {
/** Durable job state and acceptance metadata. */
readonly jobs: ReturnType<typeof mqJobs>;
/** Ordered native attempt ledger. */
readonly attempts: ReturnType<typeof mqJobAttempts>;
/** Provider-owned schedule definitions and next occurrences. */
readonly schedules: ReturnType<typeof mqSchedules>;
/** Native queue pause controls. */
readonly queues: ReturnType<typeof mqQueueControl>;
/** Native deduplication keys and windows. */
readonly dedupe: ReturnType<typeof mqDedupe>;
/** Durable child-flow admission and completion state. */
readonly flowChildren: ReturnType<typeof mqFlowChildren>;
/** Provider-owned parent-flow completion outbox. */
readonly flowOutbox: ReturnType<typeof mqFlowOutbox>;
}
index.ts
“../job.js” (namespace export)
Re-exports all named exports from the “../job.js” module.
Signature
export * from "../job.js";
“../postgres.js” (namespace export)
Re-exports all named exports from the “../postgres.js” module.
Signature
export * from "../postgres.js";
“./native.js” (namespace export)
Re-exports all named exports from the “./native.js” module.
Signature
export * from "./native.js";
“./schedules.js” (namespace export)
Re-exports all named exports from the “./schedules.js” module.
Signature
export * from "./schedules.js";
“./worker.js” (namespace export)
Re-exports all named exports from the “./worker.js” module.
Signature
export * from "./worker.js";
EffectMqRuntime (interface)
Signature
export interface EffectMqRuntime extends JobsAdapterRuntime {
readonly registerWorker: (options: EffectMqWorkerRegistrationOptions) => EffectMqWorkerHandle;
}
EffectMqRuntimeOptions (interface)
Signature
export interface EffectMqRuntimeOptions {
readonly native?: EffectMqNativeClient;
readonly postgresUrl?: string;
readonly tablePrefix?: string;
readonly queue?: string;
readonly schedules?: NativeScheduleOperations;
readonly pollIntervalMs?: number;
readonly maxPolls?: number;
readonly readTimeoutMs?: number;
readonly serviceOptions?: JobsServiceOptions;
}
createEffectMqRuntime
Signature
declare const createEffectMqRuntime: (options?: EffectMqRuntimeOptions) => EffectMqRuntime;
runtimeIntegration
Signature
declare const runtimeIntegration: RuntimeProviderIntegration<"effect-mq">;
native.ts
EffectMqNativeClient (interface)
Signature
export interface EffectMqNativeClient {
readonly submit: (request: NativeSubmission, context: OperationContext) => Promise<NativeReceipt>;
readonly get: (runId: string, context: OperationContext) => Promise<NativeRun>;
readonly list: (query: NativeRunQuery, context: OperationContext) => Promise<NativeRunPage>;
readonly cancel: (
runId: string,
operationId: string,
context: OperationContext,
) => Promise<NativeControlReceipt>;
readonly retry: (
request: Parameters<NonNullable<JobsAdapterRuntime["retry"]>>[0],
context: OperationContext,
) => Promise<NativeControlReceipt>;
readonly observe?: JobsAdapterRuntime["observe"];
readonly schedules?: NativeScheduleOperations;
readonly close?: () => Promise<void>;
readonly registerWorker?: (options: EffectMqWorkerRegistrationOptions) => EffectMqWorkerHandle;
}
EffectMqPostgresNativeOptions (interface)
Signature
export interface EffectMqPostgresNativeOptions {
readonly postgresUrl: string;
readonly tablePrefix?: string;
readonly queue?: string;
}
createEffectMqPostgresNativeClient
Signature
declare const createEffectMqPostgresNativeClient: (
options: EffectMqPostgresNativeOptions,
) => EffectMqNativeClient;
observe.ts
EffectMqObservationOptions (interface)
Signature
export interface EffectMqObservationOptions {
readonly pollIntervalMs?: number;
readonly maxPolls?: number;
readonly readTimeoutMs?: number;
}
observeEffectMqRun
Signature
declare const observeEffectMqRun: (
get: EffectMqNativeClient["get"],
request: NativeWatchRequest,
context: OperationContext,
options: EffectMqObservationOptions,
) => AsyncIterable<NativeObservation>;
postgres-operations-support.ts
object
Signature
declare const object: (value: unknown) => Record<string, any> | undefined;
submissionId
Signature
declare const submissionId: (request: NativeSubmission) => string;
submissionMetadata
Signature
declare const submissionMetadata: (
request: NativeSubmission,
context: OperationContext,
) => Readonly<Record<string, string>>;
text
Signature
declare const text: (value: unknown, fallback: string) => string;
postgres-operations.ts
NativeReceiptValue (type alias)
Signature
type NativeReceiptValue = NativeSubmissionReceipt;
cancelEffectMqRun
Signature
declare const cancelEffectMqRun: (
state: EffectMqPostgresState,
runId: string,
operationId: string,
context: OperationContext,
) => Promise<NativeControlReceipt>;
getEffectMqRun
Signature
declare const getEffectMqRun: (
state: EffectMqPostgresState,
runId: string,
context: OperationContext,
) => Promise<NativeRun>;
listEffectMqRuns
Signature
declare const listEffectMqRuns: (
state: EffectMqPostgresState,
query: NativeRunQuery,
context: OperationContext,
) => Promise<NativeRunPage>;
readRecord
Signature
declare const readRecord: (
state: EffectMqPostgresState,
runId: string,
signal: AbortSignal,
) => Promise<JobStore.JobRecord | undefined>;
retryEffectMqRun
Signature
declare const retryEffectMqRun: (
state: EffectMqPostgresState,
request: NativeRetryRequest,
context: OperationContext,
) => Promise<NativeControlReceipt>;
submitEffectMq
Signature
declare const submitEffectMq: (
state: EffectMqPostgresState,
request: NativeSubmission,
context: OperationContext,
) => Promise<NativeReceiptValue>;
postgres-query.ts
matches
Signature
declare const matches: (query: NativeRunQuery, run: NativeRun) => boolean;
metadataFilter
Signature
declare const metadataFilter: (query: NativeRunQuery) => Readonly<Record<string, unknown>>;
states
Signature
declare const states: (
statuses: NativeRunQuery["status"],
) => readonly JobStore.JobState[] | undefined;
terminal
Signature
declare const terminal: (status: RunSnapshot["status"]) => boolean;
terminalState
Signature
declare const terminalState: (state: JobStore.JobState) => boolean;
postgres-schedules.ts
createEffectMqPostgresSchedules
Signature
declare const createEffectMqPostgresSchedules: (
getState: () => EffectMqPostgresState,
queue: string | undefined,
) => NativeScheduleOperations;
postgres-snapshots.ts
effectMqSnapshot
Signature
declare const effectMqSnapshot: (
state: EffectMqPostgresState,
record: JobStore.JobRecord,
context: OperationContext,
) => Promise<NativeRun>;
statusOf
Signature
declare const statusOf: (record: JobStore.JobRecord) => NativeRun["status"];
postgres-state-support.ts
attempts
Signature
declare const attempts: (policy: unknown) => number | undefined;
bindingFrom
Signature
declare const bindingFrom: (
envelope: TaskExecutionEnvelope,
signal: AbortSignal,
) => TaskExecutionBinding;
envelopeFrom
Signature
declare const envelopeFrom: (
input: unknown,
definition: EffectMqTaskDefinition,
context: Worker.JobContext,
) => TaskExecutionEnvelope;
postgres-state.ts
EffectMqPostgresState (interface)
Signature
export interface EffectMqPostgresState {
readonly jobs: Map<string, EffectMqJobDefinition["job"]>;
readonly definitions: Map<string, EffectMqTaskDefinition>;
readonly run: <A>(effect: Effect.Effect<A, unknown, unknown>, signal?: AbortSignal) => Promise<A>;
readonly ready: () => Promise<void>;
readonly ensureJob: (name: string) => EffectMqJobDefinition["job"];
readonly workerStarted: boolean;
readonly close: () => Promise<void>;
}
EffectMqPostgresStateOptions (interface)
Signature
export interface EffectMqPostgresStateOptions {
readonly postgresUrl: string;
readonly tablePrefix?: string;
readonly queue?: string;
readonly definitions?: readonly EffectMqTaskDefinition[];
readonly executor?: TaskExecutor;
readonly startWorker?: boolean;
}
createEffectMqPostgresState
Signature
declare const createEffectMqPostgresState: (
options: EffectMqPostgresStateOptions,
) => EffectMqPostgresState;
schedules.ts
EffectMqScheduleBridge (interface)
Signature
export interface EffectMqScheduleBridge {
readonly store: EffectMqScheduleStore;
readonly run: <A>(effect: Effect.Effect<A, unknown, unknown>) => Promise<A>;
readonly jobName: string;
readonly queue?: string;
}
EffectMqScheduleStore (interface)
Signature
export interface EffectMqScheduleStore {
readonly listSchedules: (options?: {
readonly jobName?: string;
readonly group?: string;
}) => Effect.Effect<ReadonlyArray<EffectScheduleRecord>, unknown, unknown>;
readonly upsertSchedule: (
schedule: EffectScheduleRecord,
) => Effect.Effect<void, unknown, unknown>;
readonly removeSchedule: (key: ScheduleKey) => Effect.Effect<boolean, unknown, unknown>;
}
createEffectMqScheduleOperations
Maps effect-mq JobSchedules’ native Postgres records to the RELKIT schedule SPI.
Signature
declare const createEffectMqScheduleOperations: (
options: EffectMqScheduleBridge,
) => NativeScheduleOperations;
support.ts
optionalText
Signature
declare const optionalText: (value: unknown) => string | undefined;
worker.ts
EffectMqTaskDefinition (interface)
Signature
export interface EffectMqTaskDefinition {
readonly id: string;
readonly jobId: string;
readonly taskId: string;
readonly version: string;
readonly taskVersion?: string;
readonly buildId: string;
readonly policy?: unknown;
readonly schedules?: readonly unknown[];
}
EffectMqWorkerHandle (interface)
Signature
export interface EffectMqWorkerHandle {
readonly definitions: readonly EffectMqTaskDefinition[];
readonly ready: () => Promise<void>;
readonly close: () => Promise<void>;
}
EffectMqWorkerRegistrationOptions (interface)
Signature
export interface EffectMqWorkerRegistrationOptions {
readonly definitions: readonly EffectMqTaskDefinition[];
readonly executor: TaskExecutor;
readonly startWorker?: boolean;
readonly register?: (definitions: readonly EffectMqTaskDefinition[]) => Promise<void> | void;
}
createEffectMqWorker
Signature
declare const createEffectMqWorker: (
options: EffectMqWorkerRegistrationOptions,
) => EffectMqWorkerHandle;