127 lines
3.7 KiB
C
127 lines
3.7 KiB
C
/*
|
|
* 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 TDENGINE_CLIENTINT_H
|
|
#define TDENGINE_CLIENTINT_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "taos.h"
|
|
#include "taosmsg.h"
|
|
#include "thash.h"
|
|
#include "tlist.h"
|
|
#include "trpc.h"
|
|
#include "tdef.h"
|
|
|
|
typedef struct SQueryExecMetric {
|
|
int64_t start; // start timestamp
|
|
int64_t parsed; // start to parse
|
|
int64_t send; // start to send to server
|
|
int64_t rsp; // receive response from server
|
|
} SQueryExecMetric;
|
|
|
|
typedef struct SInstanceActivity {
|
|
uint64_t numOfInsertsReq;
|
|
uint64_t numOfInsertRows;
|
|
uint64_t insertElapsedTime;
|
|
uint64_t insertBytes; // submit to tsdb since launched.
|
|
|
|
uint64_t fetchBytes;
|
|
uint64_t queryElapsedTime;
|
|
uint64_t numOfSlowQueries;
|
|
uint64_t totalRequests;
|
|
uint64_t currentRequests; // the number of SRequestObj
|
|
} SInstanceActivity;
|
|
|
|
typedef struct SHeartBeatInfo {
|
|
void *pTimer; // timer, used to send request msg to mnode
|
|
} SHeartBeatInfo;
|
|
|
|
typedef struct SAppInstInfo {
|
|
int64_t numOfConns;
|
|
SRpcCorEpSet mgmtEp;
|
|
SInstanceActivity summary;
|
|
SList *pConnList; // STscObj linked list
|
|
char clusterId[TSDB_CLUSTER_ID_LEN];
|
|
} SAppInstInfo;
|
|
|
|
typedef struct SAppInfo {
|
|
int64_t startTime;
|
|
char appName[TSDB_APP_NAME_LEN];
|
|
char *ep;
|
|
int32_t pid;
|
|
int32_t numOfThreads;
|
|
SHeartBeatInfo hb;
|
|
SHashObj *pInstMap;
|
|
} SAppInfo;
|
|
|
|
typedef struct STscObj {
|
|
char user[TSDB_USER_LEN];
|
|
char pass[TSDB_PASSWORD_LEN];
|
|
char acctId[TSDB_ACCT_ID_LEN];
|
|
char db[TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN];
|
|
uint32_t connId;
|
|
uint64_t id; // ref ID returned by taosAddRef
|
|
// struct SSqlObj *sqlList;
|
|
// SRpcObj *pRpcObj;
|
|
pthread_mutex_t mutex; // used to protect the operation on db
|
|
int32_t numOfReqs; // number of sqlObj from this tscObj
|
|
SAppInstInfo *pAppInfo;
|
|
} STscObj;
|
|
|
|
typedef struct SReqBody {
|
|
tsem_t rspSem; // not used now
|
|
void* fp;
|
|
void* param;
|
|
} SRequestBody;
|
|
|
|
typedef struct SRequestObj {
|
|
uint64_t requestId;
|
|
int32_t type; // request type
|
|
STscObj *pTscObj;
|
|
SQueryExecMetric metric;
|
|
char *sqlstr; // sql string
|
|
SRequestBody body;
|
|
int64_t self;
|
|
char *msgBuf;
|
|
int32_t code;
|
|
void *pInfo; // sql parse info, generated by parser module
|
|
} SRequestObj;
|
|
|
|
extern int32_t tscReqRef;
|
|
extern void *tscQhandle;
|
|
extern int32_t tscConnRef;
|
|
extern void *tscRpcCache;
|
|
extern pthread_mutex_t rpcObjMutex;
|
|
|
|
void* createTscObj(const char* user, const char* auth, const char *ip, uint32_t port);
|
|
void destroyTscObj(void* pTscObj);
|
|
|
|
void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t type);
|
|
void destroyRequest(void* p);
|
|
|
|
TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, const char *auth, const char *db, uint16_t port);
|
|
|
|
void taos_init_imp(void);
|
|
int taos_options_imp(TSDB_OPTION option, const char *str);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // TDENGINE_CLIENTINT_H
|