提交 3dfb9bb0 编写于 作者: M Minghao Li

sync refactor

上级 c462ef61
...@@ -24,8 +24,7 @@ extern "C" { ...@@ -24,8 +24,7 @@ extern "C" {
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "cJSON.h" #include "cJSON.h"
#include "sync.h" #include "syncInt.h"
#include "syncRaftEntry.h"
#include "taosdef.h" #include "taosdef.h"
// encode as uint32 // encode as uint32
......
...@@ -24,19 +24,24 @@ extern "C" { ...@@ -24,19 +24,24 @@ extern "C" {
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "syncInt.h" #include "syncInt.h"
#include "syncMessage.h"
#include "taosdef.h" #include "taosdef.h"
typedef struct SSyncRaftEntry { typedef struct SSyncRaftEntry {
uint32_t bytes; uint32_t bytes;
uint32_t msgType; uint32_t msgType;
uint32_t originalRpcType;
uint64_t seqNum;
bool isWeak;
SyncTerm term; SyncTerm term;
SyncIndex index; SyncIndex index;
int8_t flag;
uint32_t dataLen; uint32_t dataLen;
char data[]; char data[];
} SSyncRaftEntry; } SSyncRaftEntry;
SSyncRaftEntry* syncEntryBuild(SyncClientRequest* pMsg, SyncTerm term, SyncIndex index);
void syncEntryDestory(SSyncRaftEntry* pEntry);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -37,10 +37,10 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode); ...@@ -37,10 +37,10 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode);
void logStoreDestory(SSyncLogStore* pLogStore); void logStoreDestory(SSyncLogStore* pLogStore);
// append one log entry // append one log entry
int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SRpcMsg* pEntry); int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry);
// get one log entry, user need to free pEntry->pCont // get one log entry, user need to free pEntry->pCont
int32_t logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index, SRpcMsg* pEntry); int32_t logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index, SSyncRaftEntry* pEntry);
// truncate log with index, entries after the given index (>=index) will be deleted // truncate log with index, entries after the given index (>=index) will be deleted
int32_t logStoreTruncate(SSyncLogStore* pLogStore, SyncIndex fromIndex); int32_t logStoreTruncate(SSyncLogStore* pLogStore, SyncIndex fromIndex);
......
...@@ -14,3 +14,7 @@ ...@@ -14,3 +14,7 @@
*/ */
#include "syncRaftEntry.h" #include "syncRaftEntry.h"
SSyncRaftEntry* syncEntryBuild(SyncClientRequest* pMsg, SyncTerm term, SyncIndex index) {}
void syncEntryDestory(SSyncRaftEntry* pEntry) {}
\ No newline at end of file
...@@ -44,10 +44,10 @@ void logStoreDestory(SSyncLogStore* pLogStore) { ...@@ -44,10 +44,10 @@ void logStoreDestory(SSyncLogStore* pLogStore) {
} }
// append one log entry // append one log entry
int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SRpcMsg* pEntry) {} int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) {}
// get one log entry, user need to free pEntry->pCont // get one log entry, user need to free pEntry->pCont
int32_t logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index, SRpcMsg* pEntry) {} int32_t logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index, SSyncRaftEntry* pEntry) {}
// truncate log with index, entries after the given index (>=index) will be deleted // truncate log with index, entries after the given index (>=index) will be deleted
int32_t logStoreTruncate(SSyncLogStore* pLogStore, SyncIndex fromIndex) {} int32_t logStoreTruncate(SSyncLogStore* pLogStore, SyncIndex fromIndex) {}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册