tconfig.h 2.7 KB
Newer Older
S
slguan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * 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_CFG_H
#define TDENGINE_CFG_H

#ifdef __cplusplus
extern "C" {
#endif

23 24

#define TSDB_CFG_MAX_NUM    129
S
slguan 已提交
25 26 27 28 29 30 31 32 33 34 35
#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 已提交
36
#define MAX_FLOAT    100000
T
tickduan 已提交
37
#define MIN_FLOAT    0
T
tickduan 已提交
38

S
slguan 已提交
39 40 41 42 43 44 45 46 47
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 已提交
48
  TAOS_CFG_VTYPE_INT8,
S
slguan 已提交
49 50
  TAOS_CFG_VTYPE_INT16,
  TAOS_CFG_VTYPE_INT32,
51
  TAOS_CFG_VTYPE_UINT16,
S
slguan 已提交
52 53 54 55
  TAOS_CFG_VTYPE_FLOAT,
  TAOS_CFG_VTYPE_STRING,
  TAOS_CFG_VTYPE_IPSTR,
  TAOS_CFG_VTYPE_DIRECTORY,
S
TD-1767  
Shengliang Guan 已提交
56
  TAOS_CFG_VTYPE_DATA_DIRCTORY,
T
tickduan 已提交
57
  TAOS_CFG_VTYPE_DOUBLE,
S
slguan 已提交
58 59 60 61 62 63
};

enum {
  TAOS_CFG_UTYPE_NONE,
  TAOS_CFG_UTYPE_PERCENT,
  TAOS_CFG_UTYPE_GB,
H
Haojun Liao 已提交
64
  TAOS_CFG_UTYPE_MB,
S
slguan 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78
  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 已提交
79
  int32_t  ptrLength;
S
slguan 已提交
80 81 82 83 84 85 86 87 88
} SGlobalCfg;

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

void taosReadGlobalLogCfg();
bool taosReadGlobalCfg();
void taosPrintGlobalCfg();
S
stephenkgu 已提交
89
void taosDumpGlobalCfg();
S
slguan 已提交
90 91 92

void taosInitConfigOption(SGlobalCfg cfg);
SGlobalCfg * taosGetConfigOption(const char *option);
wmmhello's avatar
wmmhello 已提交
93
bool taosReadConfigOption(const char *option, char *value, char *value2, char *value3, int8_t cfgStatus, int8_t sourceType);
S
slguan 已提交
94 95 96 97 98 99

#ifdef __cplusplus
}
#endif

#endif  // TDENGINE_TGLOBALCFG_H