summaryrefslogtreecommitdiff
path: root/infra/stellar_core.c
diff options
context:
space:
mode:
authoryangwei <[email protected]>2024-11-05 09:39:10 +0800
committeryangwei <[email protected]>2024-11-05 10:22:22 +0800
commit7f81e465226e60caa516ae82556c9411339e77cd (patch)
tree550872b92d7ac79f8dc9175fe12d42c167a62fc0 /infra/stellar_core.c
parenta4157944287874d60378e4e48b9415eb44f0b0e2 (diff)
🦄 refactor(stellar_module to module): simplify stellar module to module
Diffstat (limited to 'infra/stellar_core.c')
-rw-r--r--infra/stellar_core.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/infra/stellar_core.c b/infra/stellar_core.c
index e072c4f..cbab9f5 100644
--- a/infra/stellar_core.c
+++ b/infra/stellar_core.c
@@ -3,7 +3,7 @@
#include <sys/prctl.h>
#include "stellar/stellar.h"
-#include "stellar/module_manager.h"
+#include "stellar/module.h"
#include "packet_io.h"
#include "log_internal.h"
@@ -37,7 +37,7 @@ struct stellar
struct logger *logger;
struct packet_io *pkt_io;
struct mq_schema *mq_schema;
- struct stellar_module_manager *mod_mgr;
+ struct module_manager *mod_mgr;
struct thread threads[MAX_THREAD_NUM];
};
@@ -51,15 +51,16 @@ static void *worker_thread(void *arg)
uint16_t thread_id = thread->idx;
struct stellar *st = thread->st;
struct packet_io *pkt_io = st->pkt_io;
- struct stellar_module_manager *mod_mgr = st->mod_mgr;
+ struct module_manager *mod_mgr = st->mod_mgr;
struct mq_runtime *mq_rt = mq_runtime_new(st->mq_schema);
- struct packet_manager *pkt_mgr = stellar_module_get_packet_manager(mod_mgr);
+ struct module *pkt_mgr_mod= module_manager_get_module(mod_mgr, PACKET_MANAGER_MODULE_NAME);
+ struct packet_manager *pkt_mgr = module_to_packet_manager(pkt_mgr_mod);
snprintf(thread_name, sizeof(thread_name), "stellar:%d", thread_id);
prctl(PR_SET_NAME, (unsigned long long)thread_name, NULL, NULL, NULL);
__thread_local_logger = st->logger;
- stellar_module_manager_register_thread(mod_mgr, thread_id, mq_rt);
+ module_manager_register_thread(mod_mgr, thread_id, mq_rt);
ATOMIC_SET(&thread->is_runing, 1);
CORE_LOG_FATAL("worker thread %d runing", thread_id);
@@ -94,7 +95,7 @@ static void *worker_thread(void *arg)
}
}
- stellar_module_manager_unregister_thread(mod_mgr, thread_id);
+ module_manager_unregister_thread(mod_mgr, thread_id);
mq_runtime_free(mq_rt);
ATOMIC_SET(&thread->is_runing, 0);
@@ -172,7 +173,7 @@ struct stellar *stellar_new(const char *toml_file)
goto error_out;
}
- st->mod_mgr = stellar_module_manager_new(toml_file, st->thread_num, st->mq_schema, st->logger);
+ st->mod_mgr = module_manager_new(toml_file, st->thread_num, st->mq_schema, st->logger);
if (st->mod_mgr == NULL)
{
CORE_LOG_ERROR("unable to create packet manager");
@@ -227,7 +228,7 @@ void stellar_free(struct stellar *st)
if (st)
{
packet_io_free(st->pkt_io);
- stellar_module_manager_free(st->mod_mgr);
+ module_manager_free(st->mod_mgr);
mq_schema_free(st->mq_schema);
CORE_LOG_FATAL("stellar exit\n");