MCPcopy Create free account
hub / github.com/effect-app/libs / replaceExec

Function replaceExec

packages/infra/src/WorkflowEngineCosmos.ts:241–261  ·  view source on GitHub ↗
(doc: ExecDoc)

Source from the content-addressed store, hash-verified

239 .pipe(annotate("readExec", executionId))
240
241 const replaceExec = (doc: ExecDoc) =>
242 Effect
243 .gen(function*() {
244 const resp = yield* Effect.tryPromise(() =>
245 container.item(execId, doc._partitionKey).replace<ExecDoc>(doc, {
246 accessCondition: { type: "IfMatch", condition: doc._etag ?? "" }
247 })
248 )
249 yield* annotateCosmosResponse({ requestCharge: resp.requestCharge, statusCode: resp.statusCode })
250 return { ...doc, _etag: resp.etag }
251 })
252 .pipe(
253 Effect.catch((u) =>
254 isOptimisticError(u)
255 ? Effect.fail(
256 new OptimisticConcurrencyException({ type: "workflow.exec", id: doc._partitionKey, code: 412 })
257 )
258 : Effect.die(u)
259 ),
260 annotate("replaceExec", doc._partitionKey)
261 )
262
263 // Atomic create-or-noop using a single-op batch — returns true if created.
264 const createIfMissing = <T extends { readonly id: string; readonly _partitionKey: string }>(

Callers 4

tryClaimFunction · 0.70
heartbeatFunction · 0.70
driveFunction · 0.70
markInterruptedFunction · 0.70

Calls 8

annotateCosmosResponseFunction · 0.90
isOptimisticErrorFunction · 0.85
itemMethod · 0.80
catchMethod · 0.80
annotateFunction · 0.70
pipeMethod · 0.65
replaceMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…