This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
stellar-stellar/infra/plugin_manager/plugin_manager_interna.h
2024-09-06 19:48:29 +08:00

145 lines
2.9 KiB
C

#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
#include "plugin_manager.h"
#include "stellar/stellar.h"
#include "stellar/stellar_mq.h"
#include "stellar/stellar_exdata.h"
#include "uthash/utarray.h"
struct stellar_message;
struct per_thread_exdata_array
{
struct stellar_exdata *exdata_array;
};
struct plugin_manager_per_thread_data
{
struct per_thread_exdata_array per_thread_pkt_exdata_array;
struct stellar_message *priority_mq[STELLAR_MQ_PRIORITY_MAX];// message list
struct stellar_message *dealth_letter_queue;// dlq list
unsigned long long pub_packet_msg_cnt;
};
struct plugin_manager_schema
{
struct stellar *st;
UT_array *plugin_load_specs_array;
UT_array *stellar_exdata_schema_array;
UT_array *stellar_mq_schema_array;
UT_array *registered_packet_plugin_array;
UT_array *registered_polling_plugin_array;
int stellar_mq_topic_num;
int mq_topic_subscriber_num;
unsigned int max_message_dispatch;
struct plugin_manager_per_thread_data *per_thread_data;
}__attribute__((aligned(sizeof(void*))));
enum plugin_exdata_state
{ INIT, ACTIVE, EXIT };
struct stellar_exdata
{
struct plugin_manager_schema *plug_mgr;
void *exdata;
enum plugin_exdata_state state;
};
struct stellar_exdata_schema
{
char *name;
stellar_exdata_free *free_func;
void *free_arg;
int idx;
}__attribute__((aligned(sizeof(void*))));
struct stellar_message
{
struct stellar *st;
struct
{
int topic_id;
enum stellar_mq_priority priority;
} header;
void *body;
struct stellar_message *next, *prev;
} __attribute__((aligned(sizeof(void *))));
typedef struct stellar_mq_subscriber
{
int topic_subscriber_idx;
int plugin_idx;
on_msg_cb_func *plugin_msg_cb;
struct stellar_mq_subscriber *next, *prev;
}stellar_mq_subscriber __attribute__((aligned(sizeof(void*))));
struct stellar_mq_topic_schema
{
char *topic_name;
int topic_id;
int subscriber_cnt;
int is_destroyed;
on_msg_dispatch_cb_func *dispatch_cb;
void *dispatch_cb_arg;
stellar_msg_free_cb_func *free_cb;
void *free_cb_arg;
struct stellar_mq_subscriber *subscribers;
}__attribute__((aligned(sizeof(void*))));
enum packet_stage
{
PACKET_STAGE_INPUT=0,
PACKET_STAGE_OUTPUT,
PACKET_STAGE_MAX
};
struct registered_plugin_schema
{
char ip_protocol;
plugin_on_packet_func *on_packet[PACKET_STAGE_MAX];
void *plugin_env;
UT_array *registed_mq_subscriber_info;
}__attribute__((aligned(sizeof(void*))));
struct registered_polling_plugin_schema
{
plugin_on_polling_func *on_polling;
void *plugin_env;
}__attribute__((aligned(sizeof(void*))));
struct stellar_mq_subscriber_info
{
int topic_id;
int subscriber_idx;
}__attribute__((aligned(sizeof(void*))));
/*******************************
* PLUGIN MANAGER INIT & EXIT *
*******************************/
#include <dlfcn.h>
struct plugin_specific
{
char plugin_name[256];
plugin_on_load_func *load_cb;
plugin_on_unload_func *unload_cb;
void *plugin_ctx;
}__attribute__((aligned(sizeof(void*))));
#ifdef __cplusplus
}
#endif