Does it have workflow library with retries and streaming?
Does it have a library for creating workflows with retries and streaming support?
Perfect! Let me provide you with a comprehensive answer based on what I've found.
##Summary
Yes, Effect-TS has a comprehensive library for creating workflows with retries and durable execution, called @effect/workflow. However, it does not currently have built-in streaming support within the workflow system itself, though the broader Effect library has excellent streaming capabilities that can be used separately.
###Key Features of @effect/workflow:
####1. Workflow Creation
The library allows you to define durable workflows using Workflow.make():
const EmailWorkflow = Workflow.make({
name: "EmailWorkflow",
success: Schema.Void,
error: SendEmailError,
payload: {
id: Schema.String,
to: Schema.String
},
idempotencyKey: ({ id }) => id
})
####2. Built-in Retry Support
-
Activity Retries: Each activity can be retried with
Activity.retry():Activity.make({ name: "SendEmail", execute: Effect.gen(function* () { ... }) }).pipe( Activity.retry({ times: 5 }) ) -
Interrupt Retry Policy: Activities automatically handle interruptions with exponential backoff and retry logic (up to 10 times with exponential backoff).
####3. Durable Primitives
The library provides:
-
DurableClock: Pause workflows for specified durations without consuming resourcesyield* DurableClock.sleep({ name: "Some sleep", duration: "10 seconds" }) -
DurableDeferred: Create signals that can be awaited later for async operations -
DurableQueue: Process items from a persistent queue within a workflow with concurrency control and retry scheduling:const ApiQueue = DurableQueue.make({ name: "ApiQueue", payload: { id: Schema.String }, idempotencyKey(payload) { return payload.id } }) yield* DurableQueue.process(ApiQueue, { id: "api-call-1" }) -
DurableRateLimiter: Rate limiting within workflows
####4. Compensation Handlers
Workflows support cleanup/compensation logic on failure:
EmailWorkflow.withCompensation(
Effect.fn(function* (value, cause) {
yield* Effect.log(`Compensating activity`)
})
)
###Regarding Streaming:
While the workflow library itself doesn't have native streaming support, the underlying Effect library has excellent streaming capabilities (Stream) that can be composed with workflows. The library is designed to work with persistent storage backends (e.g., PostgreSQL via @effect/sql-pg) for durability.
END OF POST