🦄 refactor(plugin manager): Updating interface definitions

This commit is contained in:
yangwei
2022-07-27 14:11:29 +08:00
parent 717f52e4c1
commit 4735a8073a
6 changed files with 42 additions and 41 deletions

View File

@@ -9,8 +9,8 @@
struct stellar_event_base_loop_arg
{
struct packet_io_device *dev;
struct session_manager_handle *session_mgr;
struct plugin_manager_handle *plug_mgr;
struct session_manager *session_mgr;
struct plugin_manager *plug_mgr;
int tid;
};
@@ -55,8 +55,8 @@ struct packet_io_device *packet_io_init(int worker_thread_num, const char *insta
int main(int argc, char ** argv)
{
//manager_init
struct session_manager_handle *session_mgr = session_manager_init();
struct plugin_manager_handle *plug_mgr = plugin_manager_init();
struct session_manager *session_mgr = session_manager_init();
struct plugin_manager *plug_mgr = plugin_manager_init();
//register build-in plugin
plugin_manager_event_register(plug_mgr, "HTTP", http_decoder, nullptr);

View File

@@ -1,8 +1,8 @@
#include <sys/queue.h>
#include <time.h>
#include "deps/uthash/uthash.h"
#include "sdk/include/session.h"
#include "session_manager.h"
#if 0
@@ -30,6 +30,21 @@ struct plugin_manager
#endif
struct stellar_plugin_ctx
{
void *call_back_arg;
const struct timeval timeout;
fn_session_event_callback call_back;
TAILQ_ENTRY(stellar_plugin_ctx) tqe;
};
TAILQ_HEAD(stellar_plugin_ctx_list, stellar_plugin_ctx);
struct stellar_plugin_data
{
stellar_plugin_ctx_list plugin_ctx_list;
};
struct plugin_manager_handle *plugin_manager_init()
{
return nullptr;
@@ -40,7 +55,7 @@ int plugin_manager_load(const char *plugin_conf_path)
return 0;
}
int plugin_manager_event_register(struct plugin_manager_handle *h,
int plugin_manager_event_register(struct plugin_manager *h,
const char *session_type_name,
fn_session_event_callback call_back,
const struct timeval *timeout)
@@ -48,7 +63,7 @@ int plugin_manager_event_register(struct plugin_manager_handle *h,
return 0;
}
void plugin_manager_dispatch(struct plugin_manager_handle *h, struct stellar_event *event)
void plugin_manager_dispatch(struct plugin_manager *h, struct stellar_event *event)
{
#if 0
struct session *s = container_of(event, struct session, cur_ev);

View File

@@ -1,35 +1,20 @@
#pragma once
#include <sys/queue.h>
#include <time.h>
#include "sdk/include/session.h"
#include "sdk/include/plugin.h"
struct stellar_plugin_ctx
{
void *call_back_arg;
const struct timeval timeout;
fn_session_event_callback call_back;
TAILQ_ENTRY(stellar_plugin_ctx) tqe;
};
TAILQ_HEAD(stellar_plugin_ctx_list, stellar_plugin_ctx);
struct plugin_manager;
struct plugin_manager *plugin_manager_init();
struct stellar_plugin_data
{
stellar_plugin_ctx_list plugin_ctx_list;
};
struct plugin_manager_handle;
struct plugin_manager_handle *plugin_manager_init();
int plugin_manager_event_register(struct plugin_manager_handle *h,
int plugin_manager_event_register(struct plugin_manager *h,
const char *session_type_name,
fn_session_event_callback call_back,
const struct timeval *timeout);
int plugin_manager_load(const char *plugin_conf_path);
void plugin_manager_dispatch(struct plugin_manager_handle *h, struct stellar_event *ev);
void plugin_manager_dispatch(struct plugin_manager *h, struct stellar_event *ev);

View File

@@ -5,7 +5,7 @@ struct session_manager
struct stellar_session **tcp_table, **udp_table;
};
struct session_manager_handle *session_manager_init()
struct session_manager *session_manager_init()
{
return nullptr;
}
@@ -24,13 +24,13 @@ struct stellar_session *session_manager_session_derive(const struct stellar_sess
return nullptr;
}
struct stellar_event *session_manager_commit(struct session_manager_handle *h, struct stellar_packet *p)
struct stellar_event *session_manager_commit(struct session_manager *h, struct stellar_packet *p)
{
return nullptr;
};
struct stellar_event *session_manager_fetch_event(struct session_manager_handle *h)
struct stellar_event *session_manager_fetch_event(struct session_manager *h)
{
return nullptr;
}

View File

@@ -12,11 +12,11 @@ struct stellar_session_event_data
struct stellar_plugin_data *plugin_data;
};
struct session_manager_handle;
struct session_manager_handle *session_manager_init();
struct session_manager;
struct session_manager *session_manager_init();
struct stellar_event *session_manager_commit(struct session_manager_handle *session_mgr, struct stellar_packet *pkt);
struct stellar_event *session_manager_fetch_event(struct session_manager_handle *session_mgr);
struct stellar_event *session_manager_commit(struct session_manager *session_mgr, struct stellar_packet *pkt);
struct stellar_event *session_manager_fetch_event(struct session_manager *session_mgr);
struct stellar_session
{