diff options
| author | yangwei <[email protected]> | 2024-09-14 12:18:26 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2024-09-14 12:18:26 +0800 |
| commit | 1f55a6f2405ce209d04d7b71df593aef4474d1ed (patch) | |
| tree | 17e5eb5d0840adc60bf58651f9c736070b74c247 /include | |
| parent | 0b142cd0bb38169936c516772d84c9b4e4201cae (diff) | |
✨ feat(module manager): from plugin manager to module manager
Diffstat (limited to 'include')
| -rw-r--r-- | include/stellar/module_manager.h | 40 | ||||
| -rw-r--r-- | include/stellar/stellar.h | 10 |
2 files changed, 41 insertions, 9 deletions
diff --git a/include/stellar/module_manager.h b/include/stellar/module_manager.h new file mode 100644 index 0000000..a626575 --- /dev/null +++ b/include/stellar/module_manager.h @@ -0,0 +1,40 @@ +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "stellar/mq.h" + +struct stellar_module; +struct stellar_module *stellar_module_new(const char *name); +void stellar_module_free(struct stellar_module *mod); + +void * stellar_module_get_ctx(struct stellar_module *mod); +void stellar_module_set_ctx(struct stellar_module *mod, void *ctx); + +const char *stellar_module_get_name(struct stellar_module* mod); + +struct stellar_module_manager; + +typedef struct stellar_module *module_on_init_func(struct stellar_module_manager *mod_mgr); +typedef void module_on_exit_func(struct stellar_module_manager *mod_mgr, struct stellar_module *mod); + +struct stellar_module_manager *stellar_module_manager_new(const char *module_spec_toml_path, int max_thread_num, struct mq_schema *mq_schema); +void stellar_module_manager_free(struct stellar_module_manager *mod_mgr); + +struct stellar_module *stellar_module_manager_get_module(struct stellar_module_manager *mod_mgr, const char *module_name); + +void stellar_module_manager_register_thread(struct stellar_module_manager* mod_mgr, int thread_id, struct mq_runtime *mq_rt); + +// 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_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); + +#ifdef __cplusplus +} +#endif
\ No newline at end of file diff --git a/include/stellar/stellar.h b/include/stellar/stellar.h index cc66cfe..397e1a4 100644 --- a/include/stellar/stellar.h +++ b/include/stellar/stellar.h @@ -7,15 +7,12 @@ extern "C" #include <stdint.h> -#include "stellar/mq.h" #include "stellar/log.h" #include "stellar/packet.h" struct stellar; -//return plugin_env -typedef void *plugin_on_load_func(struct stellar *st); -typedef void plugin_on_unload_func(void *plugin_env); + typedef void plugin_on_packet_func(struct packet *pkt, void *on_packet_cb_arg); //return 0 if success, otherwise return -1. @@ -28,8 +25,6 @@ int stellar_polling_subscribe(struct stellar *st, plugin_on_polling_func on_pol void stellar_emit_datapath_telemetry(struct packet *pkt, const char * module, const char *str); -int stellar_get_worker_thread_num(struct stellar *st); -uint16_t stellar_get_current_thread_index(); // only send user build packet, can't send packet which come from network void stellar_send_build_packet(struct stellar *st, struct packet *pkt); @@ -40,9 +35,6 @@ void stellar_loopbreak(struct stellar *st); void stellar_reload_log_level(struct stellar *st); struct logger *stellar_get_logger(struct stellar *st); -struct mq_schema *stellar_get_mq_schema(struct stellar *st); -struct mq_runtime *stellar_get_mq_runtime(struct stellar *st); - #ifdef __cplusplus } #endif |
