Skip to content

Commit cd91be1

Browse files
committed
add alert config
1 parent b5f4db6 commit cd91be1

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

utils/ut_config.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,19 @@ int load_cfg_log(json_t *root, const char *key, log_cfg *cfg)
8383
return 0;
8484
}
8585

86+
int load_cfg_alert(json_t *root, const char *key, alert_cfg *cfg)
87+
{
88+
json_t *node = json_object_get(root, key);
89+
if (!node || !json_is_object(node))
90+
return -__LINE__;
91+
json_t *addr = json_object_get(node, "addr");
92+
if (!addr || !json_is_string(addr))
93+
return -__LINE__;
94+
ERR_RET(parse_inetv4_addr(json_string_value(addr), &cfg->addr));
95+
ERR_RET(read_cfg_str(node, "host", &cfg->host, NULL));
96+
return 0;
97+
}
98+
8699
int load_cfg_svr(json_t *root, const char *key, nw_svr_cfg *cfg)
87100
{
88101
json_t *node = json_object_get(root, key);

utils/ut_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# include "ut_log.h"
1818
# include "ut_kafka.h"
1919
# include "ut_redis.h"
20+
# include "ut_alert.h"
2021
# include "ut_decimal.h"
2122
# include "ut_rpc_clt.h"
2223
# include "ut_rpc_svr.h"
@@ -54,6 +55,7 @@ typedef struct mysql_cfg {
5455
int parse_inetv4_addr(const char *str, struct sockaddr_in *addr);
5556

5657
int load_cfg_process(json_t *root, const char *key, process_cfg *cfg);
58+
int load_cfg_alert(json_t *root, const char *key, alert_cfg *cfg);
5759
int load_cfg_log(json_t *root, const char *key, log_cfg *cfg);
5860
int load_cfg_svr(json_t *root, const char *key, nw_svr_cfg *cfg);
5961
int load_cfg_clt(json_t *root, const char *key, nw_clt_cfg *cfg);

0 commit comments

Comments
 (0)