refactor: rename id_generator to snowflake
This commit is contained in:
@@ -11,33 +11,33 @@
|
||||
|
||||
// return 0: success
|
||||
// retuun -1: failed
|
||||
static int parse_id_generator_section(toml_table_t *root, struct id_generator_options *opts)
|
||||
static int parse_snowflake_section(toml_table_t *root, struct snowflake_options *opts)
|
||||
{
|
||||
const char *ptr;
|
||||
toml_table_t *table;
|
||||
|
||||
table = toml_table_in(root, "id_generator");
|
||||
table = toml_table_in(root, "snowflake");
|
||||
if (table == NULL)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing id_generator section");
|
||||
CONFIG_LOG_ERROR("config file missing snowflake section");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr = toml_raw_in(table, "snowflake_worker_id_base");
|
||||
ptr = toml_raw_in(table, "snowflake_base");
|
||||
if (ptr == NULL)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing id_generator->snowflake_worker_id_base");
|
||||
CONFIG_LOG_ERROR("config file missing snowflake->snowflake_base");
|
||||
return -1;
|
||||
}
|
||||
opts->snowflake_worker_id_base = atoi(ptr);
|
||||
opts->snowflake_base = atoi(ptr);
|
||||
|
||||
ptr = toml_raw_in(table, "snowflake_worker_id_offset");
|
||||
ptr = toml_raw_in(table, "snowflake_offset");
|
||||
if (ptr == NULL)
|
||||
{
|
||||
CONFIG_LOG_ERROR("config file missing id_generator->snowflake_worker_id_offset");
|
||||
CONFIG_LOG_ERROR("config file missing snowflake->snowflake_offset");
|
||||
return -1;
|
||||
}
|
||||
opts->snowflake_worker_id_offset = atoi(ptr);
|
||||
opts->snowflake_offset = atoi(ptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -536,7 +536,7 @@ int stellar_config_load(struct stellar_config *config, const char *file)
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
if (parse_id_generator_section(table, &config->id_gen_opts) != 0)
|
||||
if (parse_snowflake_section(table, &config->snowflake_opts) != 0)
|
||||
{
|
||||
goto error_out;
|
||||
}
|
||||
@@ -585,13 +585,13 @@ void stellar_config_print(const struct stellar_config *config)
|
||||
}
|
||||
|
||||
const struct packet_io_options *pkt_io_opts = &config->pkt_io_opts;
|
||||
const struct id_generator_options *id_gen_opts = &config->id_gen_opts;
|
||||
const struct snowflake_options *snowflake_opts = &config->snowflake_opts;
|
||||
const struct ip_reassembly_options *ip_reass_opts = &config->ip_reass_opts;
|
||||
const struct session_manager_options *sess_mgr_opts = &config->sess_mgr_opts;
|
||||
|
||||
// id_generator config
|
||||
CONFIG_LOG_DEBUG("id_generator->snowflake_worker_id_base : %d", id_gen_opts->snowflake_worker_id_base);
|
||||
CONFIG_LOG_DEBUG("id_generator->snowflake_worker_id_offset : %d", id_gen_opts->snowflake_worker_id_offset);
|
||||
// snowflake config
|
||||
CONFIG_LOG_DEBUG("snowflake->snowflake_base : %d", snowflake_opts->snowflake_base);
|
||||
CONFIG_LOG_DEBUG("snowflake->snowflake_offset : %d", snowflake_opts->snowflake_offset);
|
||||
|
||||
// packet io config
|
||||
CONFIG_LOG_DEBUG("packet_io->mode : %s", pkt_io_opts->mode == PACKET_IO_DUMPFILE ? "dumpfile" : "marsio");
|
||||
|
||||
Reference in New Issue
Block a user