@@ -3,6 +3,12 @@ import { RedisClientOptions } from ".";
3
3
import RedisCommandsQueue from "./commands-queue" ;
4
4
import RedisSocket from "./socket" ;
5
5
6
+ export const MAINTENANCE_EVENTS = {
7
+ PAUSE_WRITING : "pause-writing" ,
8
+ RESUME_WRITING : "resume-writing" ,
9
+ TIMEOUTS_UPDATE : "timeouts-update" ,
10
+ } as const ;
11
+
6
12
export default class EnterpriseMaintenanceManager extends EventEmitter {
7
13
#commandsQueue: RedisCommandsQueue ;
8
14
#options: RedisClientOptions ;
@@ -33,7 +39,7 @@ export default class EnterpriseMaintenanceManager extends EventEmitter {
33
39
return true ;
34
40
}
35
41
}
36
- return false
42
+ return false ;
37
43
} ;
38
44
39
45
// Queue:
@@ -55,7 +61,7 @@ export default class EnterpriseMaintenanceManager extends EventEmitter {
55
61
) : Promise < void > => {
56
62
// 1 [EVENT] MOVING PN received
57
63
// 2 [ACTION] Pause writing
58
- this . emit ( "pause" ) ;
64
+ this . emit ( MAINTENANCE_EVENTS . PAUSE_WRITING ) ;
59
65
60
66
const newSocket = new RedisSocket ( {
61
67
...this . #options. socket ,
@@ -71,17 +77,20 @@ export default class EnterpriseMaintenanceManager extends EventEmitter {
71
77
// 4 [EVENT] In-flight commands completed
72
78
73
79
// 5 + 6
74
- this . emit ( "resume" , newSocket ) ;
80
+ this . emit ( MAINTENANCE_EVENTS . RESUME_WRITING , newSocket ) ;
75
81
} ;
76
82
77
83
#onMigrating = async ( ) => {
78
84
this . #commandsQueue. setMaintenanceCommandTimeout ( this . #getCommandTimeout( ) ) ;
79
- this . emit ( "maintenance" , this . #getSocketTimeout( ) ) ;
85
+ this . emit (
86
+ MAINTENANCE_EVENTS . TIMEOUTS_UPDATE ,
87
+ this . #getSocketTimeout( ) ,
88
+ ) ;
80
89
} ;
81
90
82
91
#onMigrated = async ( ) => {
83
92
this . #commandsQueue. setMaintenanceCommandTimeout ( undefined ) ;
84
- this . emit ( "maintenance" , undefined ) ;
93
+ this . emit ( MAINTENANCE_EVENTS . TIMEOUTS_UPDATE , undefined ) ;
85
94
} ;
86
95
87
96
#getSocketTimeout( ) : number | undefined {
0 commit comments