1pub mod notification;
9pub mod cache_plugin;
10pub mod async_task;
11pub mod scheduler;
12pub mod sid_plugin;
13
14use alun_core::PluginManager;
15use alun_config::AppConfig;
16use tracing::info;
17pub fn create_plugins_from_config(config: &AppConfig) -> PluginManager {
19 let mut mgr = PluginManager::new();
20 let plugins_cfg = &config.plugins;
21
22 for name in &plugins_cfg.enabled {
23 match name.as_str() {
24 "notification" => {
25 let p = notification::NotificationPlugin::from_config(
26 &plugins_cfg.notification,
27 );
28 mgr = mgr.add(p);
29 info!("插件: notification 已注册");
30 }
31 "async-task" => {
32 let p = async_task::AsyncTaskPlugin::new(
33 plugins_cfg.async_task.workers,
34 );
35 mgr = mgr.add(p);
36 info!("插件: async-task 已注册");
37 }
38 "scheduler" => {
39 let p = scheduler::SchedulerPlugin::new();
40 mgr = mgr.add(p);
41 info!("插件: scheduler 已注册");
42 }
43 "cache" => {
44 let p = cache_plugin::CachePlugin::new(&config.cache, &config.redis);
45 mgr = mgr.add(p);
46 info!("插件: cache 已注册");
47 }
48 "sid" => {
49 let p = sid_plugin::SidPlugin::new();
50 mgr = mgr.add(p);
51 info!("插件: sid 已注册");
52 }
53 _ => {
54 tracing::warn!("未知插件: {},跳过", name);
55 }
56 }
57 }
58
59 mgr
60}