Skip to content

Commit

Permalink
feat(core/supervisor): print system config
Browse files Browse the repository at this point in the history
  • Loading branch information
loyd committed Aug 11, 2023
1 parent 4ca8294 commit cf15280
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] - ReleaseDate
### Fixed
- supervisor: deadlock if a router returns `Outcome::Multicast` ([#105]).
- supervisor: print the system config, not only the custom one.

[#105]: https://github.com/elfo-rs/elfo/pull/105

Expand Down
2 changes: 1 addition & 1 deletion elfo-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<'de> Deserializer<'de> for AnyConfig {

// === SystemConfig ===

#[derive(Default, Deserialize)]
#[derive(Debug, Default, Deserialize)]
#[serde(default)]
pub(crate) struct SystemConfig {
pub(crate) logging: crate::logging::LoggingConfig,
Expand Down
2 changes: 1 addition & 1 deletion elfo-core/src/dumping/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::Deserialize;

#[derive(Clone, Deserialize)]
#[derive(Debug, Clone, Deserialize)]
#[serde(default)]
pub(crate) struct DumpingConfig {
pub(crate) disabled: bool,
Expand Down
2 changes: 1 addition & 1 deletion elfo-core/src/logging/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::{Deserialize, Deserializer};
use tracing::level_filters::LevelFilter;

#[derive(Deserialize)]
#[derive(Debug, Deserialize)]
#[serde(default)]
pub(crate) struct LoggingConfig {
#[serde(deserialize_with = "deserialize_level_filter")]
Expand Down
9 changes: 8 additions & 1 deletion elfo-core/src/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,14 @@ where
control.user_config = Some(config.get_user::<C>().clone());
self.router
.update(control.user_config.as_ref().expect("just saved"));
self.in_scope(|| info!(config = ?control.user_config.as_ref().unwrap(), "router updated"));

self.in_scope(|| {
debug!(
message = "config updated",
system = ?control.system_config,
custom = ?control.user_config.as_ref().unwrap(),
)
});
}

fn subscribe_to_statuses(&self, addr: Addr, forcing: bool) {
Expand Down
17 changes: 16 additions & 1 deletion elfo-core/src/telemetry/config.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use std::fmt;

use regex::Regex;
use serde::{
de::{Deserializer, Error},
Deserialize,
};

#[derive(Deserialize)]
#[derive(Debug, Deserialize)]
#[serde(default)]
pub(crate) struct TelemetryConfig {
pub(crate) per_actor_group: bool,
Expand All @@ -16,6 +18,19 @@ pub(crate) enum PerActorKey {
Replacement(Regex, String),
}

impl fmt::Debug for PerActorKey {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Bool(flag) => write!(f, "{:?}", flag),
Self::Replacement(pattern, template) => f
.debug_tuple("")
.field(&pattern.as_str())
.field(&template)
.finish(),
}
}
}

impl PerActorKey {
pub(crate) fn is_enabled(&self) -> bool {
match self {
Expand Down

0 comments on commit cf15280

Please sign in to comment.