pub struct Monocore { /* private fields */ }Expand description
The monocore configuration.
Implementations§
Source§impl Monocore
impl Monocore
Sourcepub fn merge(&self, other: &Monocore) -> MonocoreResult<Monocore>
pub fn merge(&self, other: &Monocore) -> MonocoreResult<Monocore>
Merges two Monocore configurations, producing a new configuration that combines both. This is used for updating running configurations while maintaining consistency.
The merge follows these rules:
- Services and groups from both configs are combined
- If a service exists in both configs, the newer version (from other) takes precedence
- If a group exists in both configs, the newer version takes precedence
- Validates that the merged configuration maintains consistency
Sourcepub fn get_changed_services<'a>(
&'a self,
other: &'a Monocore,
) -> Vec<&'a Service>
pub fn get_changed_services<'a>( &'a self, other: &'a Monocore, ) -> Vec<&'a Service>
Gets a list of services that were either added or modified in the merged configuration compared to the original configuration.
A service is considered modified if either:
- The service itself has changed
- The group the service belongs to has changed
§Returns
A vector of references to services that were either added or modified
Source§impl Monocore
impl Monocore
Sourcepub const MAX_DEPENDENCY_DEPTH: usize = 32usize
pub const MAX_DEPENDENCY_DEPTH: usize = 32usize
The maximum service dependency chain length.
Sourcepub fn builder() -> MonocoreBuilder
pub fn builder() -> MonocoreBuilder
Creates a new builder for a Monocore configuration.
This builder provides a fluent interface for configuring and creating a Monocore configuration. The builder validates the configuration during build to ensure it is valid.
§Examples
use monocore::config::Monocore;
let monocore = Monocore::builder()
.services(vec![])
.groups(vec![])
.build()
.unwrap();Sourcepub fn default_num_vcpus() -> u8
pub fn default_num_vcpus() -> u8
Returns the default number of vCPUs.
Sourcepub fn default_ram_mib() -> u32
pub fn default_ram_mib() -> u32
Returns the default amount of RAM in MiB.
Sourcepub fn get_group(&self, group_name: &str) -> Option<&Group>
pub fn get_group(&self, group_name: &str) -> Option<&Group>
Get a group by name in this configuration
Sourcepub fn get_groups(&self) -> &[Group]
pub fn get_groups(&self) -> &[Group]
Get all groups in this configuration
Sourcepub fn get_service(&self, service_name: &str) -> Option<&Service>
pub fn get_service(&self, service_name: &str) -> Option<&Service>
Get a service by name in this configuration
Sourcepub fn get_services(&self) -> &[Service]
pub fn get_services(&self) -> &[Service]
Get all services in this configuration
Sourcepub fn remove_services(&mut self, names: &[String])
pub fn remove_services(&mut self, names: &[String])
Removes specified services from the configuration in place. If service_names is None, removes all services. Groups are preserved unless all services are removed.
§Arguments
names- The set of service names to remove.
Sourcepub fn get_ordered_services(&self) -> Vec<&Service>
pub fn get_ordered_services(&self) -> Vec<&Service>
Gets all services ordered by their dependencies, such that dependencies come before dependents. This is useful for starting services in the correct order.
§Returns
A vector of service references ordered by dependencies (dependencies first)
§Note
This method assumes the configuration has already been validated (no circular dependencies). The validation is performed during configuration building.
Sourcepub fn get_group_for_service<'a>(
&'a self,
service_name: &str,
) -> MonocoreResult<Option<&'a Group>>
pub fn get_group_for_service<'a>( &'a self, service_name: &str, ) -> MonocoreResult<Option<&'a Group>>
Gets the group for a service by name.
§Arguments
service_name- The name of the service to get the group for
§Returns
Ok(Some(group))if the service exists and has a valid group configurationOk(None)if the service exists but:- Has no group specified
- References a non-existent group
Err(_)if the service doesn’t exist
Source§impl Monocore
impl Monocore
Sourcepub fn validate(&self) -> MonocoreResult<()>
pub fn validate(&self) -> MonocoreResult<()>
Performs comprehensive validation of the Monocore configuration. This includes checking for:
- Unique service and group names
- Valid group references
- Valid volume and environment references
- Service dependencies
- Service-specific configuration requirements
- Circular dependencies in the service graph
- Volume conflicts between groups
- Port conflicts within groups
Sourcepub fn check_circular_dependencies(&self) -> MonocoreResult<()>
pub fn check_circular_dependencies(&self) -> MonocoreResult<()>
Detects circular dependencies in the service dependency graph. A circular dependency occurs when services form a dependency cycle, which would prevent proper service startup ordering.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Monocore
impl<'de> Deserialize<'de> for Monocore
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Monocore
Auto Trait Implementations§
impl Freeze for Monocore
impl RefUnwindSafe for Monocore
impl Send for Monocore
impl Sync for Monocore
impl Unpin for Monocore
impl UnwindSafe for Monocore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more