From 4a883c23c5568392fbb58a9fe4b312e3bc08e868 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Sat, 9 Oct 2021 17:14:37 +0800 Subject: [PATCH] refactor tq --- include/libs/wal/wal.h | 4 ++-- include/server/vnode/tq/tq.h | 21 ++++++--------------- source/server/vnode/tq/inc/tqInt.h | 11 +++++++++++ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h index e59d60f7dc..37cd263783 100644 --- a/include/libs/wal/wal.h +++ b/include/libs/wal/wal.h @@ -60,8 +60,8 @@ void walClose(twalh); //write int64_t walWrite(twalh, int8_t msgType, void* body, uint32_t bodyLen); void walFsync(twalh, bool forceHint); -//int32_t walCommit(twalh, uint64_t ver); -//int32_t walRollback(twalh, uint64_t ver); +//int32_t walCommit(twalh, int64_t ver); +//int32_t walRollback(twalh, int64_t ver); //read int32_t walRead(twalh, SWalHead **, int64_t ver); diff --git a/include/server/vnode/tq/tq.h b/include/server/vnode/tq/tq.h index 91688e890d..dd355c8381 100644 --- a/include/server/vnode/tq/tq.h +++ b/include/server/vnode/tq/tq.h @@ -25,23 +25,14 @@ extern "C" { typedef struct STQ STQ; STQ* tqInit(void* ref_func(void*), void* unref_func(void*)); -void tqCleanUp(STQ* pTq); - -//create persistent storage for meta info such as consuming offset -//return value > 0: cgId -//return value <= 0: error code -int tqCreateGroup(STQ*); -//create ring buffer in memory and load consuming offset -int tqOpenGroup(STQ*, int cgId); -//destroy ring buffer and persist consuming offset -int tqCloseGroup(STQ*, int cgId); -//delete persistent storage for meta info -int tqDropGroup(STQ*, int cgId); - -int tqPushMsg(STQ*, void *, int64_t version); +void tqCleanUp(STQ*); + +//void* will be replace by a msg type +int tqPushMsg(STQ*, void* msg, int64_t version); int tqCommit(STQ*); -int tqHandleMsg(STQ*, void *msg); +//void* will be replace by a msg type +int tqHandleMsg(STQ*, void* msg); #ifdef __cplusplus } diff --git a/source/server/vnode/tq/inc/tqInt.h b/source/server/vnode/tq/inc/tqInt.h index 416a915456..a51f0b03af 100644 --- a/source/server/vnode/tq/inc/tqInt.h +++ b/source/server/vnode/tq/inc/tqInt.h @@ -25,6 +25,17 @@ extern "C" { //implement the array index //implement the ring buffer +//create persistent storage for meta info such as consuming offset +//return value > 0: cgId +//return value <= 0: error code +int tqCreateGroup(STQ*); +//create ring buffer in memory and load consuming offset +int tqOpenGroup(STQ*, int cgId); +//destroy ring buffer and persist consuming offset +int tqCloseGroup(STQ*, int cgId); +//delete persistent storage for meta info +int tqDropGroup(STQ*, int cgId); + #ifdef __cplusplus } #endif -- GitLab