tmsgcb.h 2.6 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

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

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

S
Shengliang Guan 已提交
41
typedef int32_t (*PutToQueueFp)(void* pMgmt, EQueueType qtype, SRpcMsg* pMsg);
42 43
typedef int32_t (*GetQueueSizeFp)(void* pMgmt, int32_t vgId, EQueueType qtype);
typedef int32_t (*SendReqFp)(const SEpSet* pEpSet, SRpcMsg* pMsg);
44 45
typedef void (*SendRspFp)(SRpcMsg* pMsg);
typedef void (*SendRedirectRspFp)(SRpcMsg* pMsg, const SEpSet* pNewEpSet);
46 47
typedef void (*RegisterBrokenLinkArgFp)(SRpcMsg* pMsg);
typedef void (*ReleaseHandleFp)(SRpcHandleInfo* pHandle, int8_t type);
48
typedef void (*ReportStartup)(const char* name, const char* desc);
S
Shengliang Guan 已提交
49 50

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

S
Shengliang Guan 已提交
63 64 65
void    tmsgSetDefault(const SMsgCb* msgcb);
int32_t tmsgPutToQueue(const SMsgCb* msgcb, EQueueType qtype, SRpcMsg* pMsg);
int32_t tmsgGetQueueSize(const SMsgCb* msgcb, int32_t vgId, EQueueType qtype);
66
int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg);
67 68
void    tmsgSendRsp(SRpcMsg* pMsg);
void    tmsgSendRedirectRsp(SRpcMsg* pMsg, const SEpSet* pNewEpSet);
69 70
void    tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg);
void    tmsgReleaseHandle(SRpcHandleInfo* pHandle, 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_*/