tmsgcb.c 1.9 KB
Newer Older
S
Shengliang Guan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * 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/>.
 */

#define _DEFAULT_SOURCE
#include "tmsgcb.h"
18
#include "taoserror.h"
S
Shengliang Guan 已提交
19

S
shm  
Shengliang Guan 已提交
20 21
static SMsgCb tsDefaultMsgCb;

S
Shengliang Guan 已提交
22
void tmsgSetDefaultMsgCb(const SMsgCb* pMsgCb) { tsDefaultMsgCb = *pMsgCb; }
S
shm  
Shengliang Guan 已提交
23

S
Shengliang Guan 已提交
24
int32_t tmsgPutToQueue(const SMsgCb* pMsgCb, EQueueType qtype, SRpcMsg* pReq) {
25
  PutToQueueFp fp = pMsgCb->queueFps[qtype];
26
  return (*fp)(pMsgCb->mgmt, pReq);
S
Shengliang Guan 已提交
27 28
}

S
Shengliang Guan 已提交
29
int32_t tmsgGetQueueSize(const SMsgCb* pMsgCb, int32_t vgId, EQueueType qtype) {
30
  GetQueueSizeFp fp = pMsgCb->qsizeFp;
31
  return (*fp)(pMsgCb->mgmt, vgId, qtype);
S
Shengliang Guan 已提交
32 33
}

34 35 36
int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pReq) {
  SendReqFp fp = tsDefaultMsgCb.sendReqFp;
  return (*fp)(epSet, pReq);
S
Shengliang Guan 已提交
37 38
}

39
void tmsgSendRsp(const SRpcMsg* pMsg) {
40
  SendRspFp fp = tsDefaultMsgCb.sendRspFp;
41
  return (*fp)(pMsg);
42
}
S
Shengliang Guan 已提交
43

44
void tmsgSendRedirectRsp(const SRpcMsg* pMsg, const SEpSet* pNewEpSet) {
45
  SendRedirectRspFp fp = tsDefaultMsgCb.sendRedirectRspFp;
46
  (*fp)(pMsg, pNewEpSet);
S
Shengliang Guan 已提交
47 48
}

49 50 51
void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg) {
  RegisterBrokenLinkArgFp fp = tsDefaultMsgCb.registerBrokenLinkArgFp;
  (*fp)(pMsg);
S
shm  
Shengliang Guan 已提交
52 53
}

54
void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type) {
55
  ReleaseHandleFp fp = tsDefaultMsgCb.releaseHandleFp;
56
  (*fp)(pHandle, type);
S
Shengliang Guan 已提交
57 58 59
}

void tmsgReportStartup(const char* name, const char* desc) {
60
  ReportStartup fp = tsDefaultMsgCb.reportStartupFp;
61
  (*fp)(name, desc);
S
Shengliang Guan 已提交
62
}