tmsgcb.h 2.8 KB
Newer Older
S
Shengliang Guan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _TD_COMMON_MSG_CB_H_
#define _TD_COMMON_MSG_CB_H_

#include "os.h"

#ifdef __cplusplus
extern "C" {
#endif

S
Shengliang Guan 已提交
25 26
typedef struct SRpcMsg      SRpcMsg;
typedef struct SEpSet       SEpSet;
S
Shengliang Guan 已提交
27
typedef struct SMgmtWrapper SMgmtWrapper;
S
shm  
Shengliang Guan 已提交
28

L
Liu Jicong 已提交
29 30 31
typedef enum {
  QUERY_QUEUE,
  FETCH_QUEUE,
32
  READ_QUEUE,
L
Liu Jicong 已提交
33 34 35 36 37 38
  WRITE_QUEUE,
  APPLY_QUEUE,
  SYNC_QUEUE,
  MERGE_QUEUE,
  QUEUE_MAX,
} EQueueType;
S
Shengliang Guan 已提交
39

S
Shengliang Guan 已提交
40
typedef int32_t (*PutToQueueFp)(SMgmtWrapper* pWrapper, SRpcMsg* pReq);
S
Shengliang Guan 已提交
41
typedef int32_t (*GetQueueSizeFp)(SMgmtWrapper* pWrapper, int32_t vgId, EQueueType qtype);
S
shm  
Shengliang Guan 已提交
42
typedef int32_t (*SendReqFp)(SMgmtWrapper* pWrapper, const SEpSet* epSet, SRpcMsg* pReq);
S
Shengliang Guan 已提交
43
typedef int32_t (*SendMnodeReqFp)(SMgmtWrapper* pWrapper, SRpcMsg* pReq);
S
shm  
Shengliang Guan 已提交
44
typedef void (*SendRspFp)(SMgmtWrapper* pWrapper, const SRpcMsg* pRsp);
M
Minghao Li 已提交
45
typedef void (*SendRedirectRspFp)(SMgmtWrapper* pWrapper, const SRpcMsg* pRsp, const SEpSet* pNewEpSet);
S
shm  
Shengliang Guan 已提交
46 47
typedef void (*RegisterBrokenLinkArgFp)(SMgmtWrapper* pWrapper, SRpcMsg* pMsg);
typedef void (*ReleaseHandleFp)(SMgmtWrapper* pWrapper, void* handle, int8_t type);
S
Shengliang Guan 已提交
48
typedef void (*ReportStartup)(SMgmtWrapper* pWrapper, const char* name, const char* desc);
S
Shengliang Guan 已提交
49 50

typedef struct {
S
Shengliang Guan 已提交
51 52 53 54 55
  SMgmtWrapper*           pWrapper;
  PutToQueueFp            queueFps[QUEUE_MAX];
  GetQueueSizeFp          qsizeFp;
  SendReqFp               sendReqFp;
  SendRspFp               sendRspFp;
M
Minghao Li 已提交
56
  SendRedirectRspFp       sendRedirectRspFp;
S
Shengliang Guan 已提交
57
  RegisterBrokenLinkArgFp registerBrokenLinkArgFp;
S
shm  
Shengliang Guan 已提交
58
  ReleaseHandleFp         releaseHandleFp;
S
Shengliang Guan 已提交
59
  ReportStartup           reportStartupFp;
60
  void*                   clientRpc;
S
Shengliang Guan 已提交
61 62
} SMsgCb;

S
shm  
Shengliang Guan 已提交
63
void    tmsgSetDefaultMsgCb(const SMsgCb* pMsgCb);
S
Shengliang Guan 已提交
64
int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pReq);
S
Shengliang Guan 已提交
65
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype);
S
shm  
Shengliang Guan 已提交
66
int32_t tmsgSendReq(const SMsgCb* pMsgCb, const SEpSet* epSet, SRpcMsg* pReq);
S
shm  
Shengliang Guan 已提交
67
void    tmsgSendRsp(const SRpcMsg* pRsp);
M
Minghao Li 已提交
68
void    tmsgSendRedirectRsp(const SRpcMsg* pRsp, const SEpSet* pNewEpSet);
S
Shengliang Guan 已提交
69
void    tmsgRegisterBrokenLinkArg(const SMsgCb* pMsgCb, SRpcMsg* pMsg);
S
shm  
Shengliang Guan 已提交
70
void    tmsgReleaseHandle(void* handle, int8_t type);
S
Shengliang Guan 已提交
71
void    tmsgReportStartup(const char* name, const char* desc);
S
Shengliang Guan 已提交
72 73 74 75 76 77

#ifdef __cplusplus
}
#endif

#endif /*_TD_COMMON_MSG_CB_H_*/