🦄 refactor(stellar_module to module): simplify stellar module to module
This commit is contained in:
@@ -45,7 +45,7 @@ struct lpi_plus_env
|
||||
unsigned int max_pkts;
|
||||
int lpip_session_exdata_idx;
|
||||
int topic_appid;
|
||||
struct stellar_module_manager *mod_mgr;
|
||||
struct module_manager *mod_mgr;
|
||||
struct lpi_plus_mapper *mapper;
|
||||
};
|
||||
|
||||
@@ -312,7 +312,7 @@ static void lpi_plus_on_session(struct session *sess, enum session_state state,
|
||||
if(appid>0 && lpi_plus_appid_update(exdata->appid, &(exdata->appid_num), appid))
|
||||
{
|
||||
struct appid_message *msg=lpi_plus_message_new(sess, exdata->appid, exdata->appid_num);
|
||||
if(0 > mq_runtime_publish_message(stellar_module_manager_get_mq_runtime(env->mod_mgr),
|
||||
if(0 > mq_runtime_publish_message(module_manager_get_mq_runtime(env->mod_mgr),
|
||||
env->topic_appid,
|
||||
msg))FREE(msg);
|
||||
}
|
||||
@@ -326,30 +326,30 @@ static void lpi_plus_exdata_free(int idx __unused, void *ex_ptr, void *arg __unu
|
||||
FREE(ex_ptr);
|
||||
}
|
||||
|
||||
void lpi_plus_exit(struct stellar_module_manager *mod_mgr, struct stellar_module *mod)
|
||||
void lpi_plus_exit(struct module_manager *mod_mgr, struct module *mod)
|
||||
{
|
||||
if(mod_mgr==NULL)return;
|
||||
if(mod)
|
||||
{
|
||||
struct lpi_plus_env *env=(struct lpi_plus_env *)stellar_module_get_ctx(mod);
|
||||
struct lpi_plus_env *env=(struct lpi_plus_env *)module_get_ctx(mod);
|
||||
lpi_free_library();
|
||||
lpi_plus_mapper_free(env->mapper);
|
||||
FREE(env);
|
||||
stellar_module_free(mod);
|
||||
module_free(mod);
|
||||
}
|
||||
}
|
||||
|
||||
struct stellar_module *lpi_plus_init(struct stellar_module_manager *mod_mgr)
|
||||
struct module *lpi_plus_init(struct module_manager *mod_mgr)
|
||||
{
|
||||
if(mod_mgr==NULL)return NULL;
|
||||
|
||||
struct lpi_plus_env *env=CALLOC(struct lpi_plus_env, 1);
|
||||
struct stellar_module *mod=stellar_module_new("LPI_PLUS", env);
|
||||
struct module *mod=module_new("LPI_PLUS", env);
|
||||
env->mod_mgr=mod_mgr;
|
||||
env->max_pkts=16;//TODO: load from toml
|
||||
|
||||
struct session_manager *sess_mgr=stellar_module_get_session_manager(mod_mgr);
|
||||
struct mq_schema *mq_s=stellar_module_manager_get_mq_schema(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);
|
||||
struct mq_schema *mq_s=module_manager_get_mq_schema(mod_mgr);
|
||||
|
||||
if(sess_mgr==NULL || mq_s==NULL)
|
||||
{
|
||||
@@ -385,12 +385,11 @@ INIT_ERROR:
|
||||
|
||||
}
|
||||
|
||||
struct lpi_plus_mapper *stellar_module_get_lpip(struct stellar_module_manager *mod_mgr)
|
||||
struct lpi_plus_mapper *module_to_lpip_mapper(struct module *mod)
|
||||
{
|
||||
if(mod_mgr==NULL)return NULL;
|
||||
struct stellar_module *mod=stellar_module_manager_get_module(mod_mgr, "LPI_PLUS");
|
||||
if(mod==NULL)return NULL;
|
||||
struct lpi_plus_env *lpi_p=(struct lpi_plus_env *)stellar_module_get_ctx(mod);
|
||||
assert(strcmp(module_get_name(mod), LPI_PLUS_MODULE_NAME) == 0);
|
||||
struct lpi_plus_env *lpi_p=(struct lpi_plus_env *)module_get_ctx(mod);
|
||||
if(lpi_p==NULL)return NULL;
|
||||
return lpi_p->mapper;
|
||||
}
|
||||
Reference in New Issue
Block a user