diff --git a/include/stellar/module_manager.h b/include/stellar/module_manager.h index fad50cf..06c51a4 100644 --- a/include/stellar/module_manager.h +++ b/include/stellar/module_manager.h @@ -27,15 +27,16 @@ void stellar_module_manager_free(struct stellar_module_manager *mod_mgr); void stellar_module_manager_register_thread(struct stellar_module_manager* mod_mgr, int thread_id, struct mq_runtime *mq_rt); -struct stellar_module *stellar_module_manager_get_module(struct stellar_module_manager *mod_mgr, const char *module_name); - // return -1 on error int stellar_module_manager_get_thread_id(struct stellar_module_manager* mod_mgr); -int stellar_module_manager_get_max_thread_num(struct stellar_module_manager* mod_mgr); +struct mq_runtime *stellar_module_manager_get_mq_runtime(struct stellar_module_manager *mod_mgr); +struct stellar_module *stellar_module_manager_get_module(struct stellar_module_manager *mod_mgr, const char *module_name); + +int stellar_module_manager_get_max_thread_num(struct stellar_module_manager* mod_mgr); const char *stellar_module_manager_get_toml_path(struct stellar_module_manager *mod_mgr); -struct mq_schema *stellar_module_get_mq_schema(struct stellar_module_manager *mod_mgr); -struct mq_runtime *stellar_module_get_mq_runtime(struct stellar_module_manager *mod_mgr); +struct mq_schema *stellar_module_manager_get_mq_schema(struct stellar_module_manager *mod_mgr); + #ifdef __cplusplus } diff --git a/infra/module_manager/module_manager.c b/infra/module_manager/module_manager.c index 5ed9402..99a7a28 100644 --- a/infra/module_manager/module_manager.c +++ b/infra/module_manager/module_manager.c @@ -147,7 +147,7 @@ int stellar_module_manager_get_max_thread_num(struct stellar_module_manager*mod_ return mod_mgr->schema.max_thread_num; } -struct mq_schema *stellar_module_get_mq_schema(struct stellar_module_manager *mod_mgr) +struct mq_schema *stellar_module_manager_get_mq_schema(struct stellar_module_manager *mod_mgr) { if(mod_mgr==NULL)return NULL; return mod_mgr->schema.mq_schema; @@ -167,7 +167,7 @@ int stellar_module_manager_get_thread_id(struct stellar_module_manager* mod_mgr return local_thread_id; } -struct mq_runtime *stellar_module_get_mq_runtime(struct stellar_module_manager *mod_mgr __unused) +struct mq_runtime *stellar_module_manager_get_mq_runtime(struct stellar_module_manager *mod_mgr __unused) { return local_mq_rt; } diff --git a/infra/module_manager/test/gtest_module_manager_main.cpp b/infra/module_manager/test/gtest_module_manager_main.cpp index 467d5b3..0758bb6 100644 --- a/infra/module_manager/test/gtest_module_manager_main.cpp +++ b/infra/module_manager/test/gtest_module_manager_main.cpp @@ -55,10 +55,10 @@ TEST(module_manager_internal, stellar_module_manager_new_with_toml) { EXPECT_TRUE(mod_mgr!=NULL); EXPECT_TRUE(stellar_module_manager_get_module(mod_mgr, "test")==NULL); EXPECT_EQ(stellar_module_manager_get_max_thread_num(mod_mgr), 10); - EXPECT_EQ(stellar_module_get_mq_schema(mod_mgr), mq_schema); + EXPECT_EQ(stellar_module_manager_get_mq_schema(mod_mgr), mq_schema); EXPECT_EQ(stellar_module_manager_get_thread_id(mod_mgr), -1);// no thread registered - EXPECT_TRUE(stellar_module_get_mq_runtime(mod_mgr)==NULL); + EXPECT_TRUE(stellar_module_manager_get_mq_runtime(mod_mgr)==NULL); stellar_module_manager_free(mod_mgr); toml_free(conf); @@ -94,9 +94,9 @@ TEST(stellar_module_manager, new_with_null_toml) { EXPECT_TRUE(mod_mgr!=NULL); EXPECT_TRUE(stellar_module_manager_get_module(mod_mgr, "test")==NULL); EXPECT_EQ(stellar_module_manager_get_max_thread_num(mod_mgr), 10); - EXPECT_EQ(stellar_module_get_mq_schema(mod_mgr), mq_schema); + EXPECT_EQ(stellar_module_manager_get_mq_schema(mod_mgr), mq_schema); - EXPECT_TRUE(stellar_module_get_mq_runtime(mod_mgr)==NULL); + EXPECT_TRUE(stellar_module_manager_get_mq_runtime(mod_mgr)==NULL); EXPECT_EQ(stellar_module_manager_get_thread_id(mod_mgr), -1);// no thread registered stellar_module_manager_free(mod_mgr); @@ -109,10 +109,10 @@ TEST(stellar_module_manager, new_with_empty_toml) { EXPECT_TRUE(mod_mgr!=NULL); EXPECT_TRUE(stellar_module_manager_get_module(mod_mgr, "test")==NULL); EXPECT_EQ(stellar_module_manager_get_max_thread_num(mod_mgr), 10); - EXPECT_EQ(stellar_module_get_mq_schema(mod_mgr), mq_schema); + EXPECT_EQ(stellar_module_manager_get_mq_schema(mod_mgr), mq_schema); EXPECT_EQ(stellar_module_manager_get_thread_id(mod_mgr), -1);// no thread registered - EXPECT_TRUE(stellar_module_get_mq_runtime(mod_mgr)==NULL); + EXPECT_TRUE(stellar_module_manager_get_mq_runtime(mod_mgr)==NULL); stellar_module_manager_free(mod_mgr); } @@ -124,16 +124,16 @@ TEST(stellar_module_manager, register_thread) { EXPECT_TRUE(mod_mgr!=NULL); - EXPECT_EQ((long)stellar_module_get_mq_schema(mod_mgr), 1); + EXPECT_EQ((long)stellar_module_manager_get_mq_schema(mod_mgr), 1); EXPECT_EQ(stellar_module_manager_get_thread_id(mod_mgr), -1);// no thread registered - EXPECT_TRUE(stellar_module_get_mq_runtime(mod_mgr)==NULL); + EXPECT_TRUE(stellar_module_manager_get_mq_runtime(mod_mgr)==NULL); struct mq_runtime *mq_rt = (struct mq_runtime*)2; stellar_module_manager_register_thread(mod_mgr, 1, mq_rt); EXPECT_EQ(stellar_module_manager_get_thread_id(mod_mgr), 1); - EXPECT_EQ((long)stellar_module_get_mq_runtime(mod_mgr), 2); + EXPECT_EQ((long)stellar_module_manager_get_mq_runtime(mod_mgr), 2); stellar_module_manager_free(mod_mgr); @@ -160,7 +160,7 @@ extern "C" void gtest_module_exit(struct stellar_module_manager *mod_mgr, struct EXPECT_EQ(stellar_module_manager_get_module(mod_mgr, "gtest"), mod); EXPECT_EQ(stellar_module_manager_get_thread_id(mod_mgr), 1); - EXPECT_EQ((long)stellar_module_get_mq_runtime(mod_mgr), 2); + EXPECT_EQ((long)stellar_module_manager_get_mq_runtime(mod_mgr), 2); stellar_module_free(mod); } @@ -183,13 +183,13 @@ TEST(module_manager, basic_module) { EXPECT_TRUE(stellar_module_manager_get_module(mod_mgr, "gtest")!=NULL); EXPECT_EQ(stellar_module_manager_get_max_thread_num(mod_mgr), 10); - EXPECT_EQ((long)stellar_module_get_mq_schema(mod_mgr), 1); + EXPECT_EQ((long)stellar_module_manager_get_mq_schema(mod_mgr), 1); struct mq_runtime *mq_rt = (struct mq_runtime*)2; stellar_module_manager_register_thread(mod_mgr, 1, mq_rt); EXPECT_EQ((long)stellar_module_manager_get_thread_id(mod_mgr), 1); - EXPECT_EQ((long)stellar_module_get_mq_runtime(mod_mgr), 2); + EXPECT_EQ((long)stellar_module_manager_get_mq_runtime(mod_mgr), 2); stellar_module_manager_free(mod_mgr); toml_free(conf);