tmsgcb.h 2.7 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
  WRITE_QUEUE,
  APPLY_QUEUE,
  SYNC_QUEUE,
37
  SYNC_RD_QUEUE,
S
Shengliang Guan 已提交
38
  STREAM_QUEUE,
L
Liu Jicong 已提交
39 40
  QUEUE_MAX,
} EQueueType;
S
Shengliang Guan 已提交
41

42
typedef bool (*UpdateDnodeInfoFp)(void* pData, int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint16_t* port);
S
Shengliang Guan 已提交
43
typedef int32_t (*PutToQueueFp)(void* pMgmt, EQueueType qtype, SRpcMsg* pMsg);
44 45
typedef int32_t (*GetQueueSizeFp)(void* pMgmt, int32_t vgId, EQueueType qtype);
typedef int32_t (*SendReqFp)(const SEpSet* pEpSet, SRpcMsg* pMsg);
46
typedef void (*SendRspFp)(SRpcMsg* pMsg);
47 48
typedef void (*RegisterBrokenLinkArgFp)(SRpcMsg* pMsg);
typedef void (*ReleaseHandleFp)(SRpcHandleInfo* pHandle, int8_t type);
49
typedef void (*ReportStartup)(const char* name, const char* desc);
S
Shengliang Guan 已提交
50 51

typedef struct {
52
  void*                   data;
53
  void*                   mgmt;
S
Shengliang 已提交
54
  void*                   clientRpc;
S
Shengliang Guan 已提交
55
  PutToQueueFp            putToQueueFp;
S
Shengliang Guan 已提交
56 57 58 59
  GetQueueSizeFp          qsizeFp;
  SendReqFp               sendReqFp;
  SendRspFp               sendRspFp;
  RegisterBrokenLinkArgFp registerBrokenLinkArgFp;
S
shm  
Shengliang Guan 已提交
60
  ReleaseHandleFp         releaseHandleFp;
S
Shengliang Guan 已提交
61
  ReportStartup           reportStartupFp;
62
  UpdateDnodeInfoFp       updateDnodeInfoFp;
S
Shengliang Guan 已提交
63 64
} SMsgCb;

S
Shengliang Guan 已提交
65 66 67
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);
68
int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg);
69
void    tmsgSendRsp(SRpcMsg* pMsg);
70 71
void    tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg);
void    tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type);
S
Shengliang Guan 已提交
72
void    tmsgReportStartup(const char* name, const char* desc);
73
bool    tmsgUpdateDnodeInfo(int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint16_t* port);
74
void    tmsgUpdateDnodeEpSet(SEpSet* epset);
S
Shengliang Guan 已提交
75 76 77 78 79 80

#ifdef __cplusplus
}
#endif

#endif /*_TD_COMMON_MSG_CB_H_*/