effectmq
Reference

Task reference

Task definitions, retry configuration, retention, storage limits, and identity.

The Task namespace defines one schema-bearing family of work. A task definition is a descriptor; it does not allocate Redis state.

Import from the package root or the stable @effectmq/core/Task subpath.

Task.make

Task.make(config): TaskDefinition

Creates a pure task definition. It does not evaluate an Effect, acquire services, or validate runtime invariants.

FieldTypeDefaultDescription
namestringrequiredTask-family name.
schemaIdstringnameStable identity of the payload, success, and failure schema family.
payloadSchema.Struct or struct fieldsrequiredPayload schema. Bare fields are wrapped with Schema.Struct.
successSchema.ToprequiredHandler success schema. Use Schema.Void for no value.
errorSchema.ToprequiredHandler failure schema. Use Schema.Never for an infallible handler.
idempotencyKey(payload) => stringrandom UUIDDerives the logical task id. Supplying it removes the Crypto requirement from identity generation.
retrySchedule or retry optionsnoneDetermines whether and when a typed handler failure is retried.
maxRetriesnumber | null5Independent retry cap. null means unbounded.
storageLimitsPartial<StorageLimits>storage defaultsPer-definition persisted-value and collection limits.
retentionPartial<RetentionPolicy>retention defaultsPer-definition terminal retention windows.

Retry options accept while, until, times, and schedule. Predicates may return a boolean or an Effect. The schedule and predicates receive the typed handler failure. Retry stops when any configured condition stops or when maxRetries is reached.

The first queue or worker operation that consumes the definition checks retry, storage, and retention integer invariants. Invalid programmer-authored configuration terminates that operation with a defect before Redis is touched; it is not a recoverable typed failure. An omitted idempotency callback can later fail with TaskIdentityGenerationError if UUID generation fails.

TaskDefinition

TaskDefinition<Payload, Success, Error, RetryR, IdentityR>
PropertyDescription
nameTask-family name.
schemaIdStable schema identity stored with values and handles.
payloadSchemaResolved payload schema.
successSchemaTerminal success schema.
errorSchemaTyped handler failure schema.
retryScheduleNormalized Effect Schedule, when configured.
maxRetriesEffective definition-level retry cap.
storageLimitsFully resolved storage limits.
retentionFully resolved retention policy.
idempotencyKeyEffectful task-id generator.

Retention defaults

Task.defaultRetentionPolicy contains millisecond durations:

FieldDefault
taskRecordMs7 days
resultMs1 day
terminalIndexMs7 days
deadLetterMs30 days
eventMs7 days

Each resource expires independently during bounded maintenance. A terminal result can expire before its task record.

Storage defaults

StorageProtocol.defaultStorageLimits supplies:

FieldDefault
maxValueBytes1 MiB
maxErrorEntries100
maxRelationships1,000
maxEventEntries10,000

maxEventEntries must be at least 1. Other storage limits and all retention durations must be non-negative safe integers.

Task.resolvePayloadSchema

resolvePayloadSchema(schemaOrFields): Schema.Struct

Returns an existing struct schema unchanged or wraps bare struct fields with Schema.Struct.

Task.Task

Alias for the decoded TaskRecord.Task model delivered to handlers. Its fields include identity, payload, optional success, error history, timestamps, attempt/stall counters, completion policies, and resolved retention limits. See TaskQueue reference for handler use.

On this page