mirror of
https://github.com/fluencelabs/redis
synced 2025-03-17 16:10:50 +00:00
Sentinel: fake PUBLISH command to receive HELLO messages.
Now the way HELLO messages are received is unified. Now it is no longer needed for Sentinels to converge to the higher configuration for a master to be able to chat via some Redis instance, the are able to directly exchanges configurations. Note that this commit does not include the (trivial) change needed to send HELLO messages to Sentinel instances as well, since for an error I committed the change in the previous commit that refactored hello messages processing into a separated function.
This commit is contained in:
parent
9dfe426fc8
commit
365094028b
@ -371,6 +371,7 @@ dictType leaderVotesDictType = {
|
||||
void sentinelCommand(redisClient *c);
|
||||
void sentinelInfoCommand(redisClient *c);
|
||||
void sentinelSetCommand(redisClient *c);
|
||||
void sentinelPublishCommand(redisClient *c);
|
||||
|
||||
struct redisCommand sentinelcmds[] = {
|
||||
{"ping",pingCommand,1,"",0,NULL,0,0,0,0,0},
|
||||
@ -379,6 +380,7 @@ struct redisCommand sentinelcmds[] = {
|
||||
{"unsubscribe",unsubscribeCommand,-1,"",0,NULL,0,0,0,0,0},
|
||||
{"psubscribe",psubscribeCommand,-2,"",0,NULL,0,0,0,0,0},
|
||||
{"punsubscribe",punsubscribeCommand,-1,"",0,NULL,0,0,0,0,0},
|
||||
{"publish",sentinelPublishCommand,3,"",0,NULL,0,0,0,0,0},
|
||||
{"info",sentinelInfoCommand,-1,"",0,NULL,0,0,0,0,0},
|
||||
{"shutdown",shutdownCommand,-1,"",0,NULL,0,0,0,0,0}
|
||||
};
|
||||
@ -2739,6 +2741,21 @@ badfmt: /* Bad format errors */
|
||||
value, option);
|
||||
}
|
||||
|
||||
/* Our fake PUBLISH command: it is actually useful only to receive hello messages
|
||||
* from the other sentinel instances, and publishing to a channel other than
|
||||
* SENTINEL_HELLO_CHANNEL is forbidden.
|
||||
*
|
||||
* Because we have a Sentinel PUBLISH, the code to send hello messages is the same
|
||||
* for all the three kind of instances: masters, slaves, sentinels. */
|
||||
void sentinelPublishCommand(redisClient *c) {
|
||||
if (strcmp(c->argv[1]->ptr,SENTINEL_HELLO_CHANNEL)) {
|
||||
addReplyError(c, "Only HELLO messages are accepted by Sentinel instances.");
|
||||
return;
|
||||
}
|
||||
sentinelProcessHelloMessage(c->argv[2]->ptr,sdslen(c->argv[2]->ptr));
|
||||
addReplyLongLong(c,1);
|
||||
}
|
||||
|
||||
/* ===================== SENTINEL availability checks ======================= */
|
||||
|
||||
/* Is this instance down from our point of view? */
|
||||
|
Loading…
x
Reference in New Issue
Block a user