tmsgcb.h 3.0 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 已提交
40 41
typedef int32_t (*PutToQueueFp)(void *pMgmt, SRpcMsg* pReq);
typedef int32_t (*GetQueueSizeFp)(void *pMgmt, 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);
S
Shengliang Guan 已提交
45
typedef void (*SendMnodeRecvFp)(SMgmtWrapper* pWrapper, SRpcMsg* pReq, SRpcMsg* pRsp);
M
Minghao Li 已提交
46
typedef void (*SendRedirectRspFp)(SMgmtWrapper* pWrapper, const SRpcMsg* pRsp, const SEpSet* pNewEpSet);
S
shm  
Shengliang Guan 已提交
47 48
typedef void (*RegisterBrokenLinkArgFp)(SMgmtWrapper* pWrapper, SRpcMsg* pMsg);
typedef void (*ReleaseHandleFp)(SMgmtWrapper* pWrapper, void* handle, int8_t type);
S
Shengliang Guan 已提交
49
typedef void (*ReportStartup)(SMgmtWrapper* pWrapper, const char* name, const char* desc);
S
Shengliang Guan 已提交
50 51

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

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

#ifdef __cplusplus
}
#endif

#endif /*_TD_COMMON_MSG_CB_H_*/