snode.h 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 18
/*
 * 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_SNODE_H_
#define _TD_SNODE_H_

L
Liu Jicong 已提交
19
#include "tmsg.h"
L
Liu Jicong 已提交
20
#include "tmsgcb.h"
L
Liu Jicong 已提交
21 22
#include "trpc.h"

S
Shengliang Guan 已提交
23 24 25 26 27
#ifdef __cplusplus
extern "C" {
#endif

/* ------------------------ TYPES EXPOSED ------------------------ */
S
Shengliang Guan 已提交
28
typedef struct SSnode SSnode;
S
Shengliang Guan 已提交
29 30

typedef struct {
L
Liu Jicong 已提交
31
  int32_t reserved;
S
Shengliang Guan 已提交
32 33 34
} SSnodeLoad;

typedef struct {
S
Shengliang Guan 已提交
35
  SMsgCb msgCb;
S
Shengliang Guan 已提交
36 37 38 39 40 41
} SSnodeOpt;

/* ------------------------ SSnode ------------------------ */
/**
 * @brief Start one Snode in Dnode.
 *
S
Shengliang Guan 已提交
42
 * @param path Path of the snode.
S
Shengliang Guan 已提交
43 44 45
 * @param pOption Option of the snode.
 * @return SSnode* The snode object.
 */
S
Shengliang Guan 已提交
46
SSnode *sndOpen(const char *path, const SSnodeOpt *pOption);
S
Shengliang Guan 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

/**
 * @brief Stop Snode in Dnode.
 *
 * @param pSnode The snode object to close.
 */
void sndClose(SSnode *pSnode);

/**
 * @brief Get the statistical information of Snode
 *
 * @param pSnode The snode object.
 * @param pLoad Statistics of the snode.
 * @return int32_t 0 for success, -1 for failure.
 */
int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad);

/**
 * @brief Process a query message.
 *
 * @param pSnode The snode object.
 * @param pMsg The request message
 * @param pRsp The response message
 */
L
Liu Jicong 已提交
71 72
int32_t sndProcessWriteMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg *pRsp);
int32_t sndProcessStreamMsg(SSnode *pSnode, SRpcMsg *pMsg);
S
Shengliang Guan 已提交
73

S
Shengliang Guan 已提交
74 75 76 77
#ifdef __cplusplus
}
#endif

L
Liu Jicong 已提交
78
#endif /*_TD_SNODE_H_*/