Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose exchange url #850

Merged
merged 4 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/nng/supplemental/nanolib/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ struct conf_exchange_node {

typedef struct conf_exchange conf_exchange;
struct conf_exchange {
char *exchange_url;
size_t count;
conf_exchange_node **nodes;
};
Expand Down
1 change: 1 addition & 0 deletions include/nng/supplemental/nanolib/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "nng/nng.h"

#define NANOMQ_BROKER_URL "NANOMQ_BROKER_URL"
#define NANOMQ_EXCHANGER_URL "NANOMQ_EXCHANGER_URL"
#define NANOMQ_DAEMON "NANOMQ_DAEMON"
#define NANOMQ_TCP_ENABLE "NANOMQ_TCP_ENABLE"
#define NANOMQ_NUM_TASKQ_THREAD "NANOMQ_MAX_TASKQ_THREAD"
Expand Down
4 changes: 3 additions & 1 deletion src/supplemental/nanolib/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ conf_init(conf *nanomq_conf)

nanomq_conf->exchange.count = 0;
nanomq_conf->exchange.nodes = NULL;
nanomq_conf->exchange.exchange_url = NULL;

nanomq_conf->parquet.enable = false;
nanomq_conf->parquet.encryption.enable= false;
Expand All @@ -946,7 +947,7 @@ conf_init(conf *nanomq_conf)
nanomq_conf->parquet.encryption.type = AES_GCM_V1;

nanomq_conf->parquet.file_count = 5;
nanomq_conf->parquet.file_size = (10240 * 1024);
nanomq_conf->parquet.file_size = (10240 * 1024);
nanomq_conf->parquet.comp_type = UNCOMPRESSED;
nanomq_conf->parquet.file_name_prefix = NULL;
nanomq_conf->parquet.dir = NULL;
Expand Down Expand Up @@ -3906,6 +3907,7 @@ void
conf_fini(conf *nanomq_conf)
{
nng_strfree(nanomq_conf->url);
nng_strfree(nanomq_conf->exchange.exchange_url);
nng_strfree(nanomq_conf->conf_file);
nng_strfree(nanomq_conf->websocket.tls_url);

Expand Down
5 changes: 5 additions & 0 deletions src/supplemental/nanolib/conf_ver2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,7 @@ conf_exchange_node_parse(conf_exchange_node *node, cJSON *obj)

hocon_read_str(node, name, exchange);
hocon_read_str(node, topic, exchange);

if (node->name == NULL || node->topic == NULL) {
log_error("invalid exchange configuration!");
return;
Expand Down Expand Up @@ -1132,10 +1133,14 @@ static void
conf_exchange_parse_ver2(conf *config, cJSON *jso)
{
cJSON *node_array = hocon_get_obj("exchange_client", jso);
cJSON *jso_parquet = cJSON_GetObjectItem(jso, "parquet");
cJSON *node_item = NULL;

conf_exchange *conf_exchange = &config->exchange;

cJSON_ArrayForEach(node_item, node_array)
{
hocon_read_str(conf_exchange, exchange_url, node_item);
conf_exchange_node *node = NNI_ALLOC_STRUCT(node);
node->sock = NULL;
node->topic = NULL;
Expand Down
1 change: 1 addition & 0 deletions src/supplemental/nanolib/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ void
read_env_conf(conf *config)
{
set_string_var(&config->url, NANOMQ_BROKER_URL);
set_string_var(&config->exchange.exchange_url, NANOMQ_EXCHANGER_URL);
set_bool_var(&config->enable, NANOMQ_TCP_ENABLE);
set_bool_var(&config->daemon, NANOMQ_DAEMON);
set_int_var(&config->num_taskq_thread, NANOMQ_NUM_TASKQ_THREAD);
Expand Down
Loading