File tree Expand file tree Collapse file tree 3 files changed +59
-58
lines changed
Expand file tree Collapse file tree 3 files changed +59
-58
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11# @effect/workflow
22
3+ ## 0.13.1
4+
5+ ### Patch Changes
6+
7+ - [ #5821 ] ( https://github.com/Effect-TS/effect/pull/5821 ) [ ` 2519056 ` ] ( https://github.com/Effect-TS/effect/commit/2519056cb3aabd3dfffa0c874dabd74e2ad98655 ) Thanks @tim-smart ! - add DurableQueue module
8+
9+ A ` DurableQueue ` wraps a ` PersistedQueue ` , providing a way to wait for items
10+ to finish processing using a ` DurableDeferred ` .
11+
12+ ``` ts
13+ import { DurableQueue , Workflow } from " @effect/workflow"
14+ import { Effect , Schema } from " effect"
15+
16+ // Define a DurableQueue that can be used to derive workers and offer items for
17+ // processing.
18+ const ApiQueue = DurableQueue .make ({
19+ name: " ApiQueue" ,
20+ payload: {
21+ id: Schema .String
22+ },
23+ success: Schema .Void ,
24+ error: Schema .Never ,
25+ idempotencyKey(payload ) {
26+ return payload .id
27+ }
28+ })
29+
30+ const MyWorkflow = Workflow .make ({
31+ name: " MyWorkflow" ,
32+ payload: {
33+ id: Schema .String
34+ },
35+ idempotencyKey : ({ id }) => id
36+ })
37+
38+ const MyWorkflowLayer = MyWorkflow .toLayer (
39+ Effect .fn (function * () {
40+ // Add an item to the DurableQueue defined above.
41+ //
42+ // When the worker has finished processing the item, the workflow will
43+ // resume.
44+ //
45+ yield * DurableQueue .process (ApiQueue , { id: " api-call-1" })
46+
47+ yield * Effect .log (" Workflow succeeded!" )
48+ })
49+ )
50+
51+ // Define a worker layer that can process items from the DurableQueue.
52+ const ApiWorker = DurableQueue .worker (
53+ ApiQueue ,
54+ Effect .fn (function * ({ id }) {
55+ yield * Effect .log (` Worker processing API call with id: ${id } ` )
56+ }),
57+ { concurrency: 5 } // Process up to 5 items concurrently
58+ )
59+ ```
60+
361## 0.13.0
462
563### Minor Changes
Original file line number Diff line number Diff line change 11{
22 "name" : " @effect/workflow" ,
33 "type" : " module" ,
4- "version" : " 0.13.0 " ,
4+ "version" : " 0.13.1 " ,
55 "description" : " Durable workflows for Effect" ,
66 "publishConfig" : {
77 "access" : " public" ,
You can’t perform that action at this time.
0 commit comments