reifydb_sub_server/subsystem/
factory.rs

1// Copyright (c) reifydb.com 2025
2// This file is licensed under the AGPL-3.0-or-later, see license.md file
3
4use reifydb_core::ioc::IocContainer;
5use reifydb_engine::{StandardCommandTransaction, StandardEngine};
6use reifydb_sub_api::{SchedulerService, Subsystem, SubsystemFactory};
7
8use crate::{config::ServerConfig, subsystem::ServerSubsystem};
9
10/// Factory for creating server subsystem instances
11pub struct ServerSubsystemFactory {
12	config: ServerConfig,
13}
14
15impl ServerSubsystemFactory {
16	/// Create a new server subsystem factory with the given configuration
17	pub fn new(config: ServerConfig) -> Self {
18		Self {
19			config,
20		}
21	}
22}
23
24impl SubsystemFactory<StandardCommandTransaction> for ServerSubsystemFactory {
25	fn create(self: Box<Self>, ioc: &IocContainer) -> reifydb_type::Result<Box<dyn Subsystem>> {
26		let engine = ioc.resolve::<StandardEngine>()?;
27		let scheduler = ioc.resolve::<SchedulerService>()?;
28		let subsystem = ServerSubsystem::new(self.config, engine, scheduler);
29		Ok(Box::new(subsystem))
30	}
31}