@temelj/workflow 0.0.0-alpha.2 → 0.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@ type WorkflowRunLookup = WorkflowRunReaderRepository;
17
17
  type WorkflowRunWriter = WorkflowRunUnconditionalWriterRepository;
18
18
  type WorkflowRunConditionalWriter = WorkflowRunConditionalWriterRepository;
19
19
  type WorkflowRunStateStore = WorkflowRunLookup & WorkflowRunWriter & WorkflowRunWriterRepository;
20
- type WorkflowCurrentEventAppender = WorkflowConditionalEventAppender;
20
+ type WorkflowCurrentEventAppender = WorkflowConditionalEventAppender & WorkflowRunLookup;
21
21
  type WorkflowLockReleaseStore = WorkflowLockListerRepository & WorkflowLockConditionalWriterRepository;
22
22
  type WorkflowChildWakeStore = WorkflowRunStateStore & WorkflowEventReader & WorkflowStepAttemptLookup;
23
23
  type WorkflowChildCascadeStore = WorkflowChildWakeStore & WorkflowLockReleaseStore;
@@ -25,10 +25,16 @@ async function appendEventIfCurrentExecution(store, history, event, executionOwn
25
25
  await history.append(async () => {
26
26
  beforeAppend?.();
27
27
  enforceWorkflowEventHistoryNextLimit(history.events, limits);
28
- const events = await store.appendEventIfRunCurrent(executionOwner, event);
29
- if (events === void 0) WorkflowStaleExecutionError.stale(executionOwner.id);
30
- appendedEvents = events;
31
- return events;
28
+ for (let attempt = 0; attempt < 16; attempt++) {
29
+ const current = await store.getRun(executionOwner.id);
30
+ if (current === void 0 || !isCurrentExecutionOwner(current, executionOwner)) WorkflowStaleExecutionError.stale(executionOwner.id);
31
+ const events = await store.appendEventIfRunCurrent(current, event);
32
+ if (events !== void 0) {
33
+ appendedEvents = events;
34
+ return events;
35
+ }
36
+ }
37
+ WorkflowStaleExecutionError.stale(executionOwner.id);
32
38
  });
33
39
  if (appendedEvents !== void 0) afterAppend?.(event, appendedEvents);
34
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temelj/workflow",
3
- "version": "0.0.0-alpha.2",
3
+ "version": "0.0.0-alpha.3",
4
4
  "description": "Durable, vendor-agnostic, extendible workflows.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -87,9 +87,9 @@
87
87
  "@temelj/event": "0.1.0",
88
88
  "@temelj/log": "0.1.0",
89
89
  "@temelj/storage": "0.4.0",
90
+ "@temelj/standard-schema": "0.1.0",
90
91
  "@temelj/string": "0.14.0",
91
- "@temelj/value": "0.14.0",
92
- "@temelj/standard-schema": "0.1.0"
92
+ "@temelj/value": "0.14.0"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@opentelemetry/sdk-metrics": "^2.10.0",