( executionId: string )
| 605 | } |
| 606 | |
| 607 | export async function readExecutionMetaState( |
| 608 | executionId: string |
| 609 | ): Promise<ExecutionMetaReadResult> { |
| 610 | const redis = getRedisClient() |
| 611 | if (!redis) { |
| 612 | if (canUseMemoryEventBuffer()) { |
| 613 | return readMemoryMeta(executionId) |
| 614 | } |
| 615 | logger.warn('getExecutionMeta: Redis client unavailable', { executionId }) |
| 616 | return { status: 'unavailable', error: 'Redis client unavailable' } |
| 617 | } |
| 618 | try { |
| 619 | const key = getMetaKey(executionId) |
| 620 | const meta = await redis.hgetall(key) |
| 621 | if (!meta || Object.keys(meta).length === 0) return { status: 'missing' } |
| 622 | if (!isExecutionStreamStatus(meta.status)) return { status: 'missing' } |
| 623 | return { |
| 624 | status: 'found', |
| 625 | meta: { |
| 626 | status: meta.status, |
| 627 | userId: meta.userId, |
| 628 | workflowId: meta.workflowId, |
| 629 | updatedAt: meta.updatedAt, |
| 630 | earliestEventId: |
| 631 | meta.earliestEventId !== undefined ? Number(meta.earliestEventId) : undefined, |
| 632 | replayStartEventId: |
| 633 | meta.replayStartEventId !== undefined ? Number(meta.replayStartEventId) : undefined, |
| 634 | }, |
| 635 | } |
| 636 | } catch (error) { |
| 637 | const message = toError(error).message |
| 638 | logger.warn('Failed to read execution meta', { |
| 639 | executionId, |
| 640 | error: message, |
| 641 | }) |
| 642 | return { status: 'unavailable', error: message } |
| 643 | } |
| 644 | } |
| 645 | |
| 646 | export async function getExecutionMeta(executionId: string): Promise<ExecutionStreamMeta | null> { |
| 647 | const result = await readExecutionMetaState(executionId) |
no test coverage detected