@eventista/ticketing-common 1.0.53 → 1.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -30,122 +30,70 @@ const RedisClusterProvider = {
|
|
|
30
30
|
callback(null, address);
|
|
31
31
|
},
|
|
32
32
|
clusterRetryStrategy: (times) => {
|
|
33
|
-
const delay = Math.min(times *
|
|
33
|
+
const delay = Math.min(times * 200, 5000);
|
|
34
34
|
logger.warn(`Retrying Redis Cluster connection: Attempt ${times}, Delay ${delay}ms`);
|
|
35
35
|
return delay;
|
|
36
36
|
},
|
|
37
37
|
redisOptions: {
|
|
38
38
|
tls: {
|
|
39
39
|
rejectUnauthorized: false,
|
|
40
|
+
checkServerIdentity: () => undefined,
|
|
41
|
+
secureProtocol: 'TLSv1_2_method',
|
|
40
42
|
},
|
|
41
|
-
connectTimeout: Number(configService.get('REDIS_CONNECT_TIMEOUT',
|
|
42
|
-
commandTimeout: Number(configService.get('REDIS_COMMAND_TIMEOUT',
|
|
43
|
+
connectTimeout: Number(configService.get('REDIS_CONNECT_TIMEOUT', 10000)),
|
|
44
|
+
commandTimeout: Number(configService.get('REDIS_COMMAND_TIMEOUT', 30000)),
|
|
43
45
|
retryStrategy: (times) => {
|
|
44
46
|
logger.warn(`Redis node connection attempt ${times} failed. Retrying...`);
|
|
45
|
-
if (times >
|
|
46
|
-
logger.error('Redis node connection failed after
|
|
47
|
+
if (times > 10) {
|
|
48
|
+
logger.error('Redis node connection failed after 10 attempts. Giving up.');
|
|
47
49
|
return null;
|
|
48
50
|
}
|
|
49
|
-
const delay = Math.min(times *
|
|
51
|
+
const delay = Math.min(times * 100, 3000);
|
|
50
52
|
logger.log(`Retrying Redis node connection in ${delay}ms`);
|
|
51
53
|
return delay;
|
|
52
54
|
},
|
|
55
|
+
keepAlive: 10000,
|
|
56
|
+
noDelay: true,
|
|
53
57
|
},
|
|
54
58
|
enableReadyCheck: true,
|
|
55
59
|
enableOfflineQueue: true,
|
|
56
60
|
scaleReads: 'slave',
|
|
57
|
-
slotsRefreshTimeout:
|
|
58
|
-
slotsRefreshInterval:
|
|
59
|
-
maxRedirections:
|
|
60
|
-
retryDelayOnFailover:
|
|
61
|
-
retryDelayOnClusterDown:
|
|
62
|
-
retryDelayOnTryAgain:
|
|
61
|
+
slotsRefreshTimeout: 15000,
|
|
62
|
+
slotsRefreshInterval: 15000,
|
|
63
|
+
maxRedirections: 20,
|
|
64
|
+
retryDelayOnFailover: 200,
|
|
65
|
+
retryDelayOnClusterDown: 2000,
|
|
66
|
+
retryDelayOnTryAgain: 200,
|
|
67
|
+
disconnectTimeout: 30000,
|
|
68
|
+
autoResendUnfulfilledCommands: true,
|
|
69
|
+
maxRetriesPerRequest: 5,
|
|
63
70
|
});
|
|
64
71
|
cluster.on('connect', () => {
|
|
65
72
|
logger.log('Connected to Redis Cluster');
|
|
66
73
|
});
|
|
67
74
|
cluster.on('ready', () => {
|
|
68
75
|
logger.log('Redis Cluster is ready');
|
|
69
|
-
try {
|
|
70
|
-
const nodes = cluster.nodes();
|
|
71
|
-
logger.log(`Cluster has ${nodes.length} nodes`);
|
|
72
|
-
nodes.forEach(node => {
|
|
73
|
-
logger.log(`Node: ${node.options.host}:${node.options.port} (${node.options.role || 'unknown role'})`);
|
|
74
|
-
});
|
|
75
|
-
logger.log('Fetching detailed cluster info...');
|
|
76
|
-
cluster.cluster('NODES', (err, result) => {
|
|
77
|
-
if (err) {
|
|
78
|
-
logger.error('Failed to get CLUSTER NODES info', err);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const nodeLines = result.split('\n').filter(line => line.trim());
|
|
82
|
-
logger.log(`CLUSTER NODES returned ${nodeLines.length} nodes`);
|
|
83
|
-
const masterNodes = [];
|
|
84
|
-
const replicaNodes = [];
|
|
85
|
-
nodeLines.forEach(line => {
|
|
86
|
-
const parts = line.split(' ');
|
|
87
|
-
const nodeId = parts[0];
|
|
88
|
-
const endpoint = parts[1].split('@')[0];
|
|
89
|
-
const flags = parts[2];
|
|
90
|
-
const master = parts[3];
|
|
91
|
-
const slots = parts.slice(8).join(' ');
|
|
92
|
-
const nodeInfo = {
|
|
93
|
-
id: nodeId,
|
|
94
|
-
endpoint,
|
|
95
|
-
flags,
|
|
96
|
-
master: master === '-' ? 'is_master' : `replica_of_${master}`,
|
|
97
|
-
slots: slots || 'no_slots'
|
|
98
|
-
};
|
|
99
|
-
if (flags.includes('master')) {
|
|
100
|
-
masterNodes.push(nodeInfo);
|
|
101
|
-
}
|
|
102
|
-
else if (flags.includes('slave')) {
|
|
103
|
-
replicaNodes.push(nodeInfo);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
logger.log(`Cluster has ${masterNodes.length} masters and ${replicaNodes.length} replicas`);
|
|
107
|
-
masterNodes.forEach(node => {
|
|
108
|
-
logger.log(`Master: ${node.endpoint} (${node.id.substring(0, 8)}), Slots: ${node.slots}`);
|
|
109
|
-
});
|
|
110
|
-
replicaNodes.forEach(node => {
|
|
111
|
-
logger.log(`Replica: ${node.endpoint} (${node.id.substring(0, 8)}), ${node.master}`);
|
|
112
|
-
});
|
|
113
|
-
if (replicaNodes.length === 0) {
|
|
114
|
-
logger.warn('No replica nodes found! scaleReads: "slave" will not work as expected.');
|
|
115
|
-
logger.warn('All read commands will be sent to master nodes.');
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
cluster.cluster('SLOTS', (err, result) => {
|
|
119
|
-
if (err) {
|
|
120
|
-
logger.error('Failed to get CLUSTER SLOTS info', err);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
logger.log(`CLUSTER SLOTS returned ${result.length} slot ranges`);
|
|
124
|
-
result.forEach(slotInfo => {
|
|
125
|
-
const startSlot = slotInfo[0];
|
|
126
|
-
const endSlot = slotInfo[1];
|
|
127
|
-
const masterHost = slotInfo[2][0];
|
|
128
|
-
const masterPort = slotInfo[2][1];
|
|
129
|
-
const replicas = slotInfo.slice(3).map(replica => `${replica[0]}:${replica[1]}`);
|
|
130
|
-
logger.log(`Slots ${startSlot}-${endSlot} -> Master: ${masterHost}:${masterPort}, Replicas: ${replicas.length > 0 ? replicas.join(', ') : 'none'}`);
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
catch (err) {
|
|
135
|
-
logger.error('Failed to get cluster nodes info', err);
|
|
136
|
-
}
|
|
137
76
|
});
|
|
138
77
|
cluster.on('error', (err) => {
|
|
139
78
|
logger.error(`Redis Cluster error: ${err.message}`, err.stack);
|
|
140
79
|
});
|
|
141
80
|
cluster.on('close', () => {
|
|
142
|
-
logger.warn('Redis Cluster connection closed');
|
|
81
|
+
logger.warn('Redis Cluster connection closed - Will attempt to reconnect automatically');
|
|
143
82
|
});
|
|
144
83
|
cluster.on('reconnecting', () => {
|
|
145
84
|
logger.log('Redis Cluster reconnecting');
|
|
146
85
|
});
|
|
147
86
|
cluster.on('end', () => {
|
|
148
|
-
logger.warn('Redis Cluster connection ended');
|
|
87
|
+
logger.warn('Redis Cluster connection ended - Will need manual reconnection');
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
logger.log('Attempting to manually reconnect to Redis Cluster...');
|
|
90
|
+
try {
|
|
91
|
+
cluster.connect();
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
logger.error('Failed to manually reconnect to Redis Cluster', error.stack);
|
|
95
|
+
}
|
|
96
|
+
}, 5000);
|
|
149
97
|
});
|
|
150
98
|
cluster.on('node error', (err, address) => {
|
|
151
99
|
logger.error(`Redis Cluster node ${address} error: ${err.message}`, err.stack);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.module.js","sourceRoot":"","sources":["../../../src/database/redis/redis.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA0D;AAC1D,2CAA6D;AAC7D,mDAA+C;AAC/C,8DAA0D;AAI1D,MAAM,oBAAoB,GAAa;IACrC,OAAO,EAAE,eAAe;IACxB,UAAU,EAAE,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