Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
pront committed Mar 4, 2025
1 parent 0b58423 commit c3c8968
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 21 deletions.
6 changes: 3 additions & 3 deletions lib/vector-common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ impl ComponentKey {
}

impl AsRef<ComponentKey> for ComponentKey {
fn as_ref(&self) -> &ComponentKey {
&self
}
fn as_ref(&self) -> &ComponentKey {
&self

Check failure on line 44 in lib/vector-common/src/config.rs

View workflow job for this annotation

GitHub Actions / Checks

this expression creates a reference which is immediately dereferenced by the compiler
}
}

impl From<String> for ComponentKey {
Expand Down
37 changes: 24 additions & 13 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::extra_context::ExtraContext;
use crate::{api, internal_events::ApiStarted};
use crate::{
cli::{handle_config_errors, LogFormat, Opts, RootOpts, WatchConfigMethod},
config::{self, Config, ConfigPath, ComponentConfig, ComponentKey},
config::{self, ComponentConfig, ComponentKey, Config, ConfigPath},
heartbeat,
internal_events::{VectorConfigLoadError, VectorQuit, VectorStarted, VectorStopped},
signal::{SignalHandler, SignalPair, SignalRx, SignalTo},
Expand Down Expand Up @@ -350,13 +350,14 @@ async fn handle_signal(
signal_handler,
allow_empty_config,
)
.await;
.await;

reload_config_from_result(
topology_controller,
new_config,
Some(component_keys.iter().map(AsRef::as_ref).collect()))
.await
Some(component_keys.iter().map(AsRef::as_ref).collect()),
)
.await
}
Ok(SignalTo::ReloadFromConfigBuilder(config_builder)) => {
let topology_controller = topology_controller.lock().await;
Expand All @@ -376,7 +377,7 @@ async fn handle_signal(
signal_handler,
allow_empty_config,
)
.await;
.await;

reload_config_from_result(topology_controller, new_config, None).await
}
Expand All @@ -392,10 +393,13 @@ async fn handle_signal(
async fn reload_config_from_result(
mut topology_controller: MutexGuard<'_, TopologyController>,
config: Result<Config, Vec<String>>,
components_to_reload: Option<Vec<&ComponentKey>>
components_to_reload: Option<Vec<&ComponentKey>>,
) -> Option<SignalTo> {
match config {
Ok(new_config) => match topology_controller.reload(new_config, components_to_reload).await {
Ok(new_config) => match topology_controller
.reload(new_config, components_to_reload)
.await
{
ReloadOutcome::FatalError(error) => Some(SignalTo::Shutdown(Some(error))),
_ => None,
},
Expand Down Expand Up @@ -537,7 +541,8 @@ pub async fn load_configs(
if let Some(watcher_conf) = watcher_conf {
for (name, sink) in config.sinks() {
let files = sink.inner.files_to_watch();
let component_config = ComponentConfig::new(files.into_iter().cloned().collect(), name.clone());
let component_config =
ComponentConfig::new(files.into_iter().cloned().collect(), name.clone());
watched_component_paths.push(component_config);
}

Expand All @@ -547,11 +552,17 @@ pub async fn load_configs(
);

// Start listening for config changes.
config::watcher::spawn_thread(watcher_conf, signal_handler.clone_tx(), watched_paths, watched_component_paths, None)
.map_err(|error| {
error!(message = "Unable to start config watcher.", %error);
exitcode::CONFIG
})?;
config::watcher::spawn_thread(
watcher_conf,
signal_handler.clone_tx(),
watched_paths,
watched_component_paths,
None,
)
.map_err(|error| {
error!(message = "Unable to start config watcher.", %error);
exitcode::CONFIG
})?;
}

config::init_log_schema(config.global.log_schema.clone(), true);
Expand Down
2 changes: 1 addition & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl ComponentConfig {
pub fn contains(&self, config_paths: &Vec<PathBuf>) -> Option<ComponentKey> {
for i in config_paths {
if self.config_paths.contains(&i) {
return Some(self.component_key.clone())
return Some(self.component_key.clone());
}
}
None
Expand Down
3 changes: 2 additions & 1 deletion src/config/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ mod tests {
let file_path = dir.join("vector.toml");
let watcher_conf = WatcherConfig::RecommendedWatcher;
let component_file_path = Vec::new(dir.join("tls.cert"), dir.join("tls.key"));
let component_config = ComponentConfig::new(component_file_path, ComponentKey::from("http"));
let component_config =
ComponentConfig::new(component_file_path, ComponentKey::from("http"));
std::fs::create_dir(&dir).unwrap();
let mut file = File::create(&file_path).unwrap();

Expand Down
5 changes: 3 additions & 2 deletions src/topology/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ pub enum ReloadOutcome {

impl TopologyController {
pub async fn reload(
&mut self, mut new_config: config::Config,
components_to_reload: Option<Vec<&config::ComponentKey>>
&mut self,
mut new_config: config::Config,
components_to_reload: Option<Vec<&config::ComponentKey>>,
) -> ReloadOutcome {
new_config
.healthchecks
Expand Down
4 changes: 3 additions & 1 deletion src/topology/running.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ impl RunningTopology {
//
// We also shutdown any component that is simply being removed entirely.
let diff = ConfigDiff::new(&self.config, &new_config);
let buffers = self.shutdown_diff(&diff, &new_config, components_to_reload).await;
let buffers = self
.shutdown_diff(&diff, &new_config, components_to_reload)
.await;

// Gives windows some time to make available any port
// released by shutdown components.
Expand Down

0 comments on commit c3c8968

Please sign in to comment.