refactor(sync): add SyncLocalCmd
This commit is contained in:
parent
7cb3112d77
commit
04c0684149
|
@ -678,24 +678,57 @@ void syncReconfigFinishPrint2(char* s, const SyncReconfigFinish* pMsg);
|
|||
void syncReconfigFinishLog(const SyncReconfigFinish* pMsg);
|
||||
void syncReconfigFinishLog2(char* s, const SyncReconfigFinish* pMsg);
|
||||
|
||||
// ---------------------------------------------
|
||||
typedef struct SyncLocalCmd {
|
||||
uint32_t bytes;
|
||||
int32_t vgId;
|
||||
uint32_t msgType;
|
||||
SRaftId srcId;
|
||||
SRaftId destId;
|
||||
|
||||
int8_t cmd;
|
||||
SyncTerm sdNewTerm // step down new term
|
||||
|
||||
} SyncLocalCmd;
|
||||
|
||||
SyncLocalCmd* syncLocalCmdBuild(uint32_t dataLen, int32_t vgId);
|
||||
void syncLocalCmdDestroy(SyncLocalCmd* pMsg);
|
||||
void syncLocalCmdSerialize(const SyncLocalCmd* pMsg, char* buf, uint32_t bufLen);
|
||||
void syncLocalCmdDeserialize(const char* buf, uint32_t len, SyncLocalCmd* pMsg);
|
||||
char* syncLocalCmdSerialize2(const SyncLocalCmd* pMsg, uint32_t* len);
|
||||
SyncLocalCmd* syncLocalCmdDeserialize2(const char* buf, uint32_t len);
|
||||
void syncLocalCmd2RpcMsg(const SyncLocalCmd* pMsg, SRpcMsg* pRpcMsg);
|
||||
void syncLocalCmdFromRpcMsg(const SRpcMsg* pRpcMsg, SyncLocalCmd* pMsg);
|
||||
SyncLocalCmd* syncLocalCmdFromRpcMsg2(const SRpcMsg* pRpcMsg);
|
||||
cJSON* syncLocalCmd2Json(const SyncLocalCmd* pMsg);
|
||||
char* syncLocalCmd2Str(const SyncLocalCmd* pMsg);
|
||||
|
||||
// for debug ----------------------
|
||||
void syncLocalCmdPrint(const SyncLocalCmd* pMsg);
|
||||
void syncLocalCmdPrint2(char* s, const SyncLocalCmd* pMsg);
|
||||
void syncLocalCmdLog(const SyncLocalCmd* pMsg);
|
||||
void syncLocalCmdLog2(char* s, const SyncLocalCmd* pMsg);
|
||||
|
||||
// on message ----------------------
|
||||
int32_t syncNodeOnPing(SSyncNode* ths, SyncPing* pMsg);
|
||||
int32_t syncNodeOnPingReply(SSyncNode* ths, SyncPingReply* pMsg);
|
||||
int32_t syncNodeOnTimer(SSyncNode* ths, SyncTimeout* pMsg);
|
||||
|
||||
int32_t syncNodeOnHeartbeat(SSyncNode* ths, SyncHeartbeat* pMsg);
|
||||
int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, SyncHeartbeatReply* pMsg);
|
||||
int32_t syncNodeOnClientRequest(SSyncNode* ths, SyncClientRequest* pMsg, SyncIndex* pRetIndex);
|
||||
int32_t syncNodeOnRequestVote(SSyncNode* ths, SyncRequestVote* pMsg);
|
||||
int32_t syncNodeOnRequestVoteReply(SSyncNode* ths, SyncRequestVoteReply* pMsg);
|
||||
|
||||
int32_t syncNodeOnAppendEntries(SSyncNode* ths, SyncAppendEntries* pMsg);
|
||||
int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
||||
|
||||
int32_t syncNodeOnSnapshot(SSyncNode* ths, SyncSnapshotSend* pMsg);
|
||||
int32_t syncNodeOnSnapshotReply(SSyncNode* ths, SyncSnapshotRsp* pMsg);
|
||||
|
||||
int32_t syncNodeOnHeartbeat(SSyncNode* ths, SyncHeartbeat* pMsg);
|
||||
int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, SyncHeartbeatReply* pMsg);
|
||||
|
||||
int32_t syncNodeOnClientRequest(SSyncNode* ths, SyncClientRequest* pMsg, SyncIndex* pRetIndex);
|
||||
int32_t syncNodeOnTimer(SSyncNode* ths, SyncTimeout* pMsg);
|
||||
int32_t syncNodeOnLocalCmd(SSyncNode* ths, SyncLocalCmd* pMsg);
|
||||
|
||||
// -----------------------------------------
|
||||
typedef int32_t (*FpOnPingCb)(SSyncNode* ths, SyncPing* pMsg);
|
||||
typedef int32_t (*FpOnPingReplyCb)(SSyncNode* ths, SyncPingReply* pMsg);
|
||||
|
|
Loading…
Reference in New Issue