Merge pull request #30313 from taosdata/feat/new-libtaos-with-ws
feat: new libtaos with websocket
This commit is contained in:
commit
dc709da4ae
|
@ -2,7 +2,7 @@
|
|||
# taosws-rs
|
||||
ExternalProject_Add(taosws-rs
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
|
||||
GIT_TAG feat/new-libtaos-with-ws
|
||||
GIT_TAG 3.0
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -13,7 +13,7 @@ IF(TD_WEBSOCKET)
|
|||
PREFIX "taosws-rs"
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs
|
||||
BUILD_ALWAYS off
|
||||
DEPENDS ${TAOS_LIB}
|
||||
DEPENDS ${TAOS_NATIVE_LIB}
|
||||
BUILD_IN_SOURCE 1
|
||||
CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config"
|
||||
PATCH_COMMAND
|
||||
|
@ -31,7 +31,7 @@ IF(TD_WEBSOCKET)
|
|||
PREFIX "taosws-rs"
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs
|
||||
BUILD_ALWAYS off
|
||||
DEPENDS ${TAOS_LIB}
|
||||
DEPENDS ${TAOS_NATIVE_LIB}
|
||||
BUILD_IN_SOURCE 1
|
||||
CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config"
|
||||
PATCH_COMMAND
|
||||
|
@ -50,7 +50,7 @@ IF(TD_WEBSOCKET)
|
|||
PREFIX "taosws-rs"
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs
|
||||
BUILD_ALWAYS off
|
||||
DEPENDS ${TAOS_LIB}
|
||||
DEPENDS ${TAOS_NATIVE_LIB}
|
||||
BUILD_IN_SOURCE 1
|
||||
CONFIGURE_COMMAND cmake -E echo "taosws-rs no need cmake to config"
|
||||
PATCH_COMMAND
|
||||
|
@ -190,12 +190,13 @@ ELSE()
|
|||
PREFIX "taosadapter"
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosadapter
|
||||
BUILD_ALWAYS off
|
||||
DEPENDS ${TAOS_LIB}
|
||||
DEPENDS ${TAOS_NATIVE_LIB}
|
||||
BUILD_IN_SOURCE 1
|
||||
CONFIGURE_COMMAND cmake -E echo "taosadapter no need cmake to config"
|
||||
PATCH_COMMAND
|
||||
COMMAND git clean -f -d
|
||||
BUILD_COMMAND
|
||||
COMMAND tree ${CMAKE_BINARY_DIR}/build/lib
|
||||
COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -ldflags "-X 'github.com/taosdata/taosadapter/v3/version.Version=${taos_version}' -X 'github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}' -X 'github.com/taosdata/taosadapter/v3/version.BuildInfo=${TD_VER_OSTYPE}-${TD_VER_CPUTYPE} ${TD_VER_DATE}'"
|
||||
|
||||
# COMMAND CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib go build -a -o taosadapter-debug -ldflags "-X 'github.com/taosdata/taosadapter/v3/version.Version=${taos_version}' -X 'github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}' -X 'github.com/taosdata/taosadapter/v3/version.BuildInfo=${TD_VER_OSTYPE}-${TD_VER_CPUTYPE} ${TD_VER_DATE}'"
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#define CONN_MODE_INVALID -1
|
||||
#define CONN_MODE_NATIVE 0
|
||||
#define CONN_MODE_WEBSOCKET 1
|
||||
#define CONN_MODE_DEFAULT CONN_MODE_NATIVE // set default mode
|
||||
|
||||
// define error show module
|
||||
#define INIT_PHASE "init"
|
||||
|
@ -71,4 +72,10 @@ int8_t getConnMode(char *arg);
|
|||
char* strToLowerCopy(const char *str);
|
||||
int32_t parseDsn(char* dsn, char **host, char **port, char **user, char **pwd, char* error);
|
||||
|
||||
int32_t setConnMode(int8_t connMode, char *dsn);
|
||||
|
||||
uint16_t defaultPort(int8_t connMode, char *dsn);
|
||||
|
||||
int8_t defaultMode(int8_t connMode, char *dsn);
|
||||
|
||||
#endif // PUB_H_
|
|
@ -21,6 +21,7 @@
|
|||
#include "geosWrapper.h"
|
||||
#include "shellAuto.h"
|
||||
#include "shellInt.h"
|
||||
#include "../../inc/pub.h"
|
||||
|
||||
SShellObj shell = {0};
|
||||
|
||||
|
@ -1347,7 +1348,7 @@ TAOS* createConnect(SShellArgs *pArgs) {
|
|||
if (pArgs->port_inputted) {
|
||||
port = pArgs->port;
|
||||
} else {
|
||||
port = pArgs->connMode == CONN_MODE_NATIVE ? DEFAULT_PORT_NATIVE : DEFAULT_PORT_WS_LOCAL;
|
||||
port = defaultPort(pArgs->connMode, pArgs->dsn);
|
||||
}
|
||||
|
||||
sprintf(show, "host:%s port:%d ", host, port);
|
||||
|
@ -1364,7 +1365,7 @@ TAOS* createConnect(SShellArgs *pArgs) {
|
|||
int32_t shellExecute(int argc, char *argv[]) {
|
||||
int32_t code = 0;
|
||||
printf(shell.info.clientVersion, shell.info.cusName,
|
||||
shell.args.connMode == CONN_MODE_NATIVE ? STR_NATIVE : STR_WEBSOCKET,
|
||||
defaultMode(shell.args.connMode, shell.args.dsn) == CONN_MODE_NATIVE ? STR_NATIVE : STR_WEBSOCKET,
|
||||
taos_get_client_info(), shell.info.cusName);
|
||||
fflush(stdout);
|
||||
|
||||
|
|
|
@ -54,18 +54,6 @@ void initArgument(SShellArgs *pArgs) {
|
|||
pArgs->port_inputted = false;
|
||||
}
|
||||
|
||||
// set conn mode
|
||||
int32_t setConnMode(int8_t connMode) {
|
||||
// set conn mode
|
||||
char * strMode = connMode == CONN_MODE_NATIVE ? STR_NATIVE : STR_WEBSOCKET;
|
||||
int32_t code = taos_options(TSDB_OPTION_DRIVER, strMode);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
fprintf(stderr, "failed to load driver since %s [0x%08X]\r\n", taos_errstr(NULL), taos_errno(NULL));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
#if !defined(WINDOWS)
|
||||
taosSetSignal(SIGBUS, shellCrashHandler);
|
||||
|
@ -113,7 +101,7 @@ int main(int argc, char *argv[]) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (setConnMode(shell.args.connMode)) {
|
||||
if (setConnMode(shell.args.connMode, shell.args.dsn)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <taos.h>
|
||||
#include "../inc/pub.h"
|
||||
|
||||
|
||||
|
@ -88,4 +89,50 @@
|
|||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
// set conn mode
|
||||
int32_t setConnMode(int8_t connMode, char *dsn) {
|
||||
// check default
|
||||
if (connMode == CONN_MODE_INVALID) {
|
||||
if (dsn && dsn[0] != 0) {
|
||||
connMode = CONN_MODE_WEBSOCKET;
|
||||
} else {
|
||||
// default
|
||||
connMode = CONN_MODE_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
// set conn mode
|
||||
char * strMode = connMode == CONN_MODE_NATIVE ? STR_NATIVE : STR_WEBSOCKET;
|
||||
int32_t code = taos_options(TSDB_OPTION_DRIVER, strMode);
|
||||
if (code != 0) {
|
||||
fprintf(stderr, "failed to load driver. since %s [0x%08X]\r\n", taos_errstr(NULL), taos_errno(NULL));
|
||||
return code;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// default mode
|
||||
int8_t defaultMode(int8_t connMode, char *dsn) {
|
||||
int8_t mode = connMode;
|
||||
if (connMode == CONN_MODE_INVALID) {
|
||||
// no input from command line or config
|
||||
if (dsn && dsn[0] != 0) {
|
||||
mode = CONN_MODE_WEBSOCKET;
|
||||
} else {
|
||||
// default
|
||||
mode = CONN_MODE_DEFAULT;
|
||||
}
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
// get default port
|
||||
uint16_t defaultPort(int8_t connMode, char *dsn) {
|
||||
// consistent with setConnMode
|
||||
int8_t mode = defaultMode(connMode, dsn);
|
||||
|
||||
// default port
|
||||
return mode == CONN_MODE_NATIVE ? DEFAULT_PORT_NATIVE : DEFAULT_PORT_WS_LOCAL;
|
||||
}
|
||||
|
|
@ -16,8 +16,6 @@
|
|||
#ifndef INC_BENCH_H_
|
||||
#define INC_BENCH_H_
|
||||
|
||||
#include "pub.h"
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#define CURL_STATICLIB
|
||||
#define ALLOW_FORBID_FUNC
|
||||
|
@ -25,6 +23,8 @@
|
|||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
#include "pub.h"
|
||||
|
||||
#ifdef LINUX
|
||||
|
||||
#ifndef _ALPINE
|
||||
|
|
|
@ -98,19 +98,6 @@ int32_t applyConfigDir(char * cfgDir){
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t setConnMode(int8_t connMode, char *dsn) {
|
||||
// set conn mode
|
||||
char * strMode = connMode == CONN_MODE_NATIVE ? STR_NATIVE : STR_WEBSOCKET;
|
||||
int32_t code = taos_options(TSDB_OPTION_DRIVER, strMode);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
engineError(INIT_PHASE, "taos_options", code);
|
||||
return -1;
|
||||
}
|
||||
|
||||
infoPrint("Connect mode is : %s\n\n", strMode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int ret = 0;
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <ctype.h>
|
||||
#include <bench.h>
|
||||
#include "benchLog.h"
|
||||
#include "pub.h"
|
||||
|
||||
char resEncodingChunk[] = "Encoding: chunked";
|
||||
char succMessage[] = "succ";
|
||||
|
@ -304,7 +305,7 @@ SBenchConn* initBenchConnImpl() {
|
|||
if (g_arguments->port_inputted) {
|
||||
port = g_arguments->port;
|
||||
} else {
|
||||
port = g_arguments->connMode == CONN_MODE_NATIVE ? DEFAULT_PORT_NATIVE : DEFAULT_PORT_WS_LOCAL;
|
||||
port = defaultPort(g_arguments->connMode, g_arguments->dsn);
|
||||
}
|
||||
|
||||
sprintf(show, "host:%s port:%d ", host, port);
|
||||
|
|
|
@ -136,7 +136,7 @@ TAOS *taosConnect(const char *dbName) {
|
|||
if (g_args.port_inputted) {
|
||||
port = g_args.port;
|
||||
} else {
|
||||
port = g_args.connMode == CONN_MODE_NATIVE ? DEFAULT_PORT_NATIVE : DEFAULT_PORT_WS_LOCAL;
|
||||
port = defaultPort(g_args.connMode, g_args.dsn);
|
||||
}
|
||||
|
||||
sprintf(show, "host:%s port:%d ", host, port);
|
||||
|
|
|
@ -10856,19 +10856,6 @@ static int inspectAvroFiles(int argc, char *argv[]) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
int32_t setConnMode(int8_t connMode) {
|
||||
// set conn mode
|
||||
char * strMode = connMode == CONN_MODE_NATIVE ? STR_NATIVE : STR_WEBSOCKET;
|
||||
int32_t code = taos_options(TSDB_OPTION_DRIVER, strMode);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
engineError(INIT_PHASE, "taos_options", code);
|
||||
return -1;
|
||||
}
|
||||
|
||||
infoPrint("\nConnect mode is : %s\n\n", strMode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
g_uniqueID = getUniqueIDFromEpoch();
|
||||
|
@ -10923,7 +10910,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
// conn mode
|
||||
if (setConnMode(g_args.connMode) != 0) {
|
||||
if (setConnMode(g_args.connMode, g_args.dsn) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue