MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / sentinelPendingScriptsCommand

Function sentinelPendingScriptsCommand

src/sentinel.cpp:981–1019  ·  view source on GitHub ↗

Implements SENTINEL PENDING-SCRIPTS command. */

Source from the content-addressed store, hash-verified

979
980/* Implements SENTINEL PENDING-SCRIPTS command. */
981void sentinelPendingScriptsCommand(client *c) {
982 listNode *ln;
983 listIter li;
984
985 addReplyArrayLen(c,listLength(sentinel.scripts_queue));
986 listRewind(sentinel.scripts_queue,&li);
987 while ((ln = listNext(&li)) != NULL) {
988 sentinelScriptJob *sj = (sentinelScriptJob*)ln->value;
989 int j = 0;
990
991 addReplyMapLen(c,5);
992
993 addReplyBulkCString(c,"argv");
994 while (sj->argv[j]) j++;
995 addReplyArrayLen(c,j);
996 j = 0;
997 while (sj->argv[j]) addReplyBulkCString(c,sj->argv[j++]);
998
999 addReplyBulkCString(c,"flags");
1000 addReplyBulkCString(c,
1001 (sj->flags & SENTINEL_SCRIPT_RUNNING) ? "running" : "scheduled");
1002
1003 addReplyBulkCString(c,"pid");
1004 addReplyBulkLongLong(c,sj->pid);
1005
1006 if (sj->flags & SENTINEL_SCRIPT_RUNNING) {
1007 addReplyBulkCString(c,"run-time");
1008 addReplyBulkLongLong(c,mstime() - sj->start_time);
1009 } else {
1010 mstime_t delay = sj->start_time ? (sj->start_time-mstime()) : 0;
1011 if (delay < 0) delay = 0;
1012 addReplyBulkCString(c,"run-delay");
1013 addReplyBulkLongLong(c,delay);
1014 }
1015
1016 addReplyBulkCString(c,"retry-num");
1017 addReplyBulkLongLong(c,sj->retry_num);
1018 }
1019}
1020
1021/* This function calls, if any, the client reconfiguration script with the
1022 * following parameters:

Callers 1

sentinelCommandFunction · 0.85

Calls 7

addReplyArrayLenFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85
addReplyMapLenFunction · 0.85
addReplyBulkCStringFunction · 0.85
addReplyBulkLongLongFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected