🦄 refactor(stellar_module to module): simplify stellar module to module

This commit is contained in:
yangwei
2024-11-05 09:39:10 +08:00
parent a415794428
commit 7f81e46522
17 changed files with 274 additions and 279 deletions

View File

@@ -7,7 +7,7 @@
#include <assert.h>
#include "stellar/appid.h"
#include "stellar/module_manager.h"
#include "stellar/module.h"
#include "stellar/session.h"
#include "stellar/utils.h"
@@ -18,7 +18,7 @@
struct test_lpip_env
{
struct stellar_module_manager *mod_mgr;
struct module_manager *mod_mgr;
struct lpi_plus_mapper *lpi_mapper;
int l7_exdata_idx;
int session_num;
@@ -152,12 +152,13 @@ static void on_session(struct session *sess, enum session_state state, struct pa
return;
}
struct stellar_module *gtest_lpip_module_init(struct stellar_module_manager *mod_mgr)
struct module *gtest_lpip_module_init(struct module_manager *mod_mgr)
{
struct test_lpip_env *env = (struct test_lpip_env *)calloc(1, sizeof(struct test_lpip_env));
env->lpi_mapper=stellar_module_get_lpip(mod_mgr);
struct session_manager *sess_mgr = stellar_module_get_session_manager(mod_mgr);
struct module *lpip_mod = module_manager_get_module(mod_mgr, LPI_PLUS_MODULE_NAME);
env->lpi_mapper=module_to_lpip_mapper(lpip_mod);
struct module *sess_mgr_mod=module_manager_get_module(mod_mgr, SESSION_MANAGER_MODULE_NAME);
struct session_manager *sess_mgr = module_to_session_manager(sess_mgr_mod);
if(sess_mgr == NULL)
{
perror("gtest_lpi_plugin_load:stellar_module_get_session_manager failed !!!\n");
@@ -172,15 +173,15 @@ struct stellar_module *gtest_lpip_module_init(struct stellar_module_manager *mod
stellar_appid_subscribe(mod_mgr, gtest_lpip_on_appid_msg, env);
printf("gtest_lpip_module_init OK!\n");
return stellar_module_new("TEST_LPIP", env);
return module_new("TEST_LPIP", env);
}
void gtest_lpip_module_exit(struct stellar_module_manager *mod_mgr, struct stellar_module *mod)
void gtest_lpip_module_exit(struct module_manager *mod_mgr, struct module *mod)
{
assert(mod_mgr!=NULL);
struct test_lpip_env *env = (struct test_lpip_env *)stellar_module_get_ctx(mod);
struct test_lpip_env *env = (struct test_lpip_env *)module_get_ctx(mod);
free(env);
printf("gtest_lpip_module_exit OK!\n");
stellar_module_free(mod);
module_free(mod);
return ;
}

View File

@@ -11,7 +11,7 @@
#include "session_internal.h"
#include "stellar/log.h"
#include "stellar/module_manager.h"
#include "stellar/module.h"
#include "stellar/session.h"
#pragma GCC diagnostic ignored "-Wunused-parameter"
@@ -431,13 +431,13 @@ error_out:
* Plugin API
******************************************************************************/
struct stellar_module *session_debugger_on_init(struct stellar_module_manager *mod_mgr)
struct module *session_debugger_on_init(struct module_manager *mod_mgr)
{
assert(mod_mgr);
struct session_manager *sess_mgr = stellar_module_get_session_manager(mod_mgr);
struct module *sess_mgr_mod=module_manager_get_module(mod_mgr, SESSION_MANAGER_MODULE_NAME);
struct session_manager *sess_mgr = module_to_session_manager(sess_mgr_mod);
assert(sess_mgr);
struct logger *logger = stellar_module_manager_get_logger(mod_mgr);
struct logger *logger = module_manager_get_logger(mod_mgr);
assert(logger);
struct session_debugger *dbg = session_debugger_new(sess_mgr, logger);
@@ -446,29 +446,29 @@ struct stellar_module *session_debugger_on_init(struct stellar_module_manager *m
return NULL;
}
struct stellar_module *dbg_mod = stellar_module_new("session_debugger", NULL);
struct module *dbg_mod = module_new("session_debugger", NULL);
if (dbg_mod == NULL)
{
session_debugger_free(dbg);
return NULL;
}
stellar_module_set_ctx(dbg_mod, dbg);
module_set_ctx(dbg_mod, dbg);
STELLAR_LOG_FATAL(dbg->logger, "session debugger", "session_debugger init")
return dbg_mod;
}
void session_debugger_on_exit(struct stellar_module_manager *mod_mgr, struct stellar_module *mod)
void session_debugger_on_exit(struct module_manager *mod_mgr, struct module *mod)
{
if (mod)
{
struct session_debugger *dbg = stellar_module_get_ctx(mod);
struct session_debugger *dbg = module_get_ctx(mod);
if (dbg)
{
STELLAR_LOG_FATAL(dbg->logger, "session debugger", "session_debugger exit")
session_debugger_free(dbg);
}
stellar_module_free(mod);
module_free(mod);
}
}