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
Shengliang Guan 已提交
20
static SMsgCb defaultMsgCb;
S
shm  
Shengliang Guan 已提交
21

S
Shengliang Guan 已提交
22
void tmsgSetDefault(const SMsgCb* msgcb) { defaultMsgCb = *msgcb; }
S
shm  
Shengliang Guan 已提交
23

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

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

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

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

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

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

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

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