refactor: Move module load code into separate function

This commit is contained in:
2025-09-10 01:49:23 +02:00
parent da04fad520
commit 1d28b43264
4 changed files with 15 additions and 9 deletions

View File

@@ -12,8 +12,8 @@ use std::time::{SystemTime, UNIX_EPOCH};
use ::config::{Environment, File};
use automation_lib::config::{FulfillmentConfig, MqttConfig};
use automation_lib::device_manager::DeviceManager;
use automation_lib::helpers;
use automation_lib::mqtt::{self, WrappedAsyncClient};
use automation_lib::{Module, helpers};
use axum::extract::{FromRef, State};
use axum::http::StatusCode;
use axum::routing::post;
@@ -141,12 +141,7 @@ async fn app() -> anyhow::Result<()> {
})?;
lua.globals().set("print", print)?;
debug!("Loading modules...");
for module in inventory::iter::<Module> {
debug!(name = module.get_name(), "Registering");
let table = module.register(&lua)?;
lua.register_module(module.get_name(), table)?;
}
automation_lib::load_modules(&lua)?;
let mqtt = lua.create_table()?;
let event_channel = device_manager.event_channel();