( executionId: string, meta: Partial<ExecutionStreamMeta> )
| 541 | } |
| 542 | |
| 543 | export async function setExecutionMeta( |
| 544 | executionId: string, |
| 545 | meta: Partial<ExecutionStreamMeta> |
| 546 | ): Promise<boolean> { |
| 547 | const redis = getRedisClient() |
| 548 | if (!redis) { |
| 549 | if (canUseMemoryEventBuffer()) { |
| 550 | const stream = getMemoryStream(executionId) |
| 551 | const status = meta.status ?? stream.meta?.status |
| 552 | if (!status) return false |
| 553 | stream.meta = { |
| 554 | ...stream.meta, |
| 555 | ...meta, |
| 556 | status, |
| 557 | updatedAt: new Date().toISOString(), |
| 558 | } |
| 559 | touchMemoryStream(stream) |
| 560 | return true |
| 561 | } |
| 562 | logger.warn('setExecutionMeta: Redis client unavailable', { executionId }) |
| 563 | return false |
| 564 | } |
| 565 | try { |
| 566 | const key = getMetaKey(executionId) |
| 567 | const payload: Record<string, string> = { |
| 568 | updatedAt: new Date().toISOString(), |
| 569 | } |
| 570 | if (meta.status) payload.status = meta.status |
| 571 | if (meta.userId) payload.userId = meta.userId |
| 572 | if (meta.workflowId) payload.workflowId = meta.workflowId |
| 573 | if (meta.earliestEventId !== undefined) payload.earliestEventId = String(meta.earliestEventId) |
| 574 | if (meta.replayStartEventId !== undefined) { |
| 575 | payload.replayStartEventId = String(meta.replayStartEventId) |
| 576 | } |
| 577 | await redis.hset(key, payload) |
| 578 | await redis.expire(key, TTL_SECONDS) |
| 579 | return true |
| 580 | } catch (error) { |
| 581 | logger.warn('Failed to update execution meta', { |
| 582 | executionId, |
| 583 | error: toError(error).message, |
| 584 | }) |
| 585 | return false |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | export async function initializeExecutionStreamMeta( |
| 590 | executionId: string, |
no test coverage detected