tconfig.h 2.6 KB
Newer Older
S
slguan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

S
Shengliang Guan 已提交
16 17
#ifndef _TD_UTIL_CONFIG_H
#define _TD_UTIL_CONFIG_H
S
slguan 已提交
18 19 20 21 22

#ifdef __cplusplus
extern "C" {
#endif

23
#define TSDB_CFG_MAX_NUM    115
S
slguan 已提交
24 25 26 27 28 29 30 31 32 33 34
#define TSDB_CFG_PRINT_LEN  23
#define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN  41

#define TSDB_CFG_CTYPE_B_CONFIG    1U   // can be configured from file
#define TSDB_CFG_CTYPE_B_SHOW      2U   // can displayed by "show configs" commands
#define TSDB_CFG_CTYPE_B_LOG       4U   // is a log type configuration
#define TSDB_CFG_CTYPE_B_CLIENT    8U   // can be displayed in the client log
#define TSDB_CFG_CTYPE_B_OPTION    16U  // can be configured by taos_options function
#define TSDB_CFG_CTYPE_B_NOT_PRINT 32U  // such as password

T
tickduan 已提交
35
#define MAX_FLOAT    100000
T
tickduan 已提交
36
#define MIN_FLOAT    0
T
tickduan 已提交
37

S
slguan 已提交
38 39 40 41 42 43 44 45 46
enum {
  TAOS_CFG_CSTATUS_NONE,     // not configured
  TAOS_CFG_CSTATUS_DEFAULT,  // use system default value
  TAOS_CFG_CSTATUS_FILE,     // configured from file
  TAOS_CFG_CSTATUS_OPTION,   // configured by taos_options function
  TAOS_CFG_CSTATUS_ARG,      // configured by program argument
};

enum {
S
Shengliang Guan 已提交
47
  TAOS_CFG_VTYPE_INT8,
S
slguan 已提交
48 49
  TAOS_CFG_VTYPE_INT16,
  TAOS_CFG_VTYPE_INT32,
50
  TAOS_CFG_VTYPE_UINT16,
S
slguan 已提交
51 52 53 54
  TAOS_CFG_VTYPE_FLOAT,
  TAOS_CFG_VTYPE_STRING,
  TAOS_CFG_VTYPE_IPSTR,
  TAOS_CFG_VTYPE_DIRECTORY,
S
TD-1767  
Shengliang Guan 已提交
55
  TAOS_CFG_VTYPE_DATA_DIRCTORY,
T
tickduan 已提交
56
  TAOS_CFG_VTYPE_DOUBLE,
S
slguan 已提交
57 58 59 60 61 62
};

enum {
  TAOS_CFG_UTYPE_NONE,
  TAOS_CFG_UTYPE_PERCENT,
  TAOS_CFG_UTYPE_GB,
H
Haojun Liao 已提交
63
  TAOS_CFG_UTYPE_MB,
S
slguan 已提交
64 65 66 67 68 69 70 71 72 73 74 75 76 77
  TAOS_CFG_UTYPE_BYTE,
  TAOS_CFG_UTYPE_SECOND,
  TAOS_CFG_UTYPE_MS
};

typedef struct {
  char *   option;
  void *   ptr;
  float    minValue;
  float    maxValue;
  int8_t   cfgType;
  int8_t   cfgStatus;
  int8_t   unitType;
  int8_t   valType;
S
TD-1037  
Shengliang Guan 已提交
78
  int32_t  ptrLength;
S
slguan 已提交
79 80 81 82 83 84
} SGlobalCfg;

extern SGlobalCfg tsGlobalConfig[];
extern int32_t    tsGlobalConfigNum;
extern char *     tsCfgStatusStr[];

85
void    taosReadGlobalLogCfg();
86 87
int32_t taosReadCfgFromFile();
void    taosPrintCfg();
88
void    taosDumpGlobalCfg();
S
slguan 已提交
89

90
void        taosAddConfigOption(SGlobalCfg cfg);
91
SGlobalCfg *taosGetConfigOption(const char *option);
S
slguan 已提交
92 93 94 95 96

#ifdef __cplusplus
}
#endif

S
Shengliang Guan 已提交
97
#endif  /*_TD_UTIL_CONFIG_H*/