-
-
Notifications
You must be signed in to change notification settings - Fork 374
/
Copy pathapp.ts
100 lines (80 loc) · 2.5 KB
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { Job, JobOptions } from 'bull'
import { Job as JobMq, JobsOptions } from 'bullmq'
import * as Redis from 'ioredis'
import React from 'react'
import { Status } from '../ui/components/constants'
export type JobCleanStatus =
| 'completed'
| 'wait'
| 'active'
| 'delayed'
| 'failed'
export type JobStatus = Status
export type JobCounts = Record<JobStatus, number>
export interface QueueAdapter {
readonly readOnlyMode: boolean
getClient(): Promise<Redis.Redis>
getName(): string
getJob(id: string): Promise<Job | JobMq | undefined | null>
getJobs(
jobStatuses: JobStatus[],
start?: number,
end?: number,
): Promise<(Job | JobMq)[]>
getJobCounts(...jobStatuses: JobStatus[]): Promise<JobCounts>
clean(queueStatus: JobCleanStatus, graceTimeMs: number): Promise<any>
setFormatter(
field: 'data' | 'returnValue',
formatter: (data: any) => any,
): void
format(field: 'data' | 'returnValue', data: any): any
}
export interface QueueAdapterOptions {
readOnlyMode: boolean
}
export interface BullBoardQueue {
queue: QueueAdapter
}
export interface BullBoardQueues {
[key: string]: BullBoardQueue
}
export interface ValidMetrics {
total_system_memory: string
redis_version: string
used_memory: string
mem_fragmentation_ratio: string
connected_clients: string
blocked_clients: string
}
export interface AppJob {
id: string | number | undefined
timestamp: number | null
processedOn?: number | null
finishedOn?: number | null
progress: JobMq['progress']
attempts: JobMq['attemptsMade']
failedReason: JobMq['failedReason']
stacktrace: string[]
opts: JobsOptions | JobOptions
data: JobMq['data']
name: JobMq['name']
delay: number | undefined
returnValue: string | Record<string | number, any> | null
}
export interface AppQueue {
name: string
counts: Record<Status, number>
jobs: AppJob[]
readOnlyMode: boolean
}
export type SelectedStatuses = Record<AppQueue['name'], Status>
export interface QueueActions {
promoteJob: (queueName: string) => (job: AppJob) => () => Promise<void>
retryJob: (queueName: string) => (job: AppJob) => () => Promise<void>
cleanJob: (queueName: string) => (job: AppJob) => () => Promise<void>
retryAll: (queueName: string) => () => Promise<void>
cleanAllDelayed: (queueName: string) => () => Promise<void>
cleanAllFailed: (queueName: string) => () => Promise<void>
cleanAllCompleted: (queueName: string) => () => Promise<void>
setSelectedStatuses: React.Dispatch<React.SetStateAction<SelectedStatuses>>
}