(doc: ExecDoc)
| 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 }>( |
no test coverage detected
searching dependent graphs…