MCPcopy
hub / github.com/redis/node-redis / pollLoop

Function pollLoop

packages/client/lib/sentinel/index.spec.ts:1266–1280  ·  view source on GitHub ↗
(phase: 'outage' | 'recovery', rounds: number)

Source from the content-addressed store, hash-verified

1264
1265 const pollResults: Array<{ phase: 'outage' | 'recovery'; status: 'success' | 'timeout' | 'error' }> = [];
1266 const pollLoop = async (phase: 'outage' | 'recovery', rounds: number) => {
1267 for (let i = 0; i < rounds; i++) {
1268 try {
1269 await timedGet();
1270 pollResults.push({ phase, status: 'success' });
1271 } catch (err) {
1272 const message = (err as { message?: string })?.message;
1273 pollResults.push({
1274 phase,
1275 status: message === '1s Timeout' ? 'timeout' : 'error'
1276 });
1277 }
1278 await setTimeout(3000);
1279 }
1280 };
1281
1282 // Match the issue's periodic GET calls while outage is active.
1283 await pollLoop('outage', 3);

Callers 1

index.spec.tsFile · 0.85

Calls 2

timedGetFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected