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 已提交
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
Shengliang Guan 已提交
44
typedef void (*SendRspFp)(const SRpcMsg* pRsp);
S
Shengliang Guan 已提交
45
typedef void (*SendRedirectRspFp)(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);
48
typedef void (*ReportStartup)(const char* name, const char* desc);
S
Shengliang Guan 已提交
49 50

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

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

#ifdef __cplusplus
}
#endif

#endif /*_TD_COMMON_MSG_CB_H_*/