Skip to content

Commit

Permalink
add params to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
devkelley committed Jan 4, 2024
1 parent 94ee888 commit 6c40e8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 5 additions & 4 deletions common/src/config_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ const AGEMO_HOME: &str = "AGEMO_HOME";
const DEFAULT_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/../config");

/// Read config from layered configuration files.
/// Searches for `{config_file_name}.default.{config_file_ext}` as the base configuration in `$AGEMO_HOME`,
/// then searches for overrides named `{config_file_name}.{config_file_ext}` in the current directory and `$AGEMO_HOME`.
/// Searches for `{config_file_name}.default.{config_file_ext}` as the base configuration,
/// then searches for overrides named `{config_file_name}.{config_file_ext}` in `$AGEMO_HOME`.
/// If `$AGEMO_HOME` is not set, it defaults to `$HOME/.agemo`.
///
/// # Arguments
/// - `config_file_name`: The config file name. This is used to construct the file names to search for.
/// - `config_file_ext`: The config file extension. This is used to construct the file names to search for.
/// * `config_file_name` - The config file name. This is used to construct the file names to search for.
/// * `config_file_ext` - The config file extension. This is used to construct the file names to search for.
/// * `args` - Optional commandline arguments. Any values set will override values gathered from config files.
pub fn read_from_files<T, A>(
config_file_name: &str,
config_file_ext: &str,
Expand Down
10 changes: 7 additions & 3 deletions pub-sub-service/src/load_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::env;

use clap::Parser;
use common::config_utils;
use log::error;
use log::{debug, error};
use proc_macros::ConfigSource;
use serde_derive::{Deserialize, Serialize};

Expand Down Expand Up @@ -80,6 +80,7 @@ pub struct Settings {
///
/// # Arguments
/// * `config_file_name` - Name of the config file to load settings from.
/// * `args` - Optional commandline config arguments.
pub fn load_config<T>(
config_file_name: &str,
args: Option<CmdConfigOptions>,
Expand All @@ -94,17 +95,20 @@ where
///
/// Will attempt to load the settings from the service configuration file. If the necessary config
/// is set will run in Chariott enabled mode, otherwise the service will run in standalone mode.
///
/// # Arguments
/// * `args` - Commandline config arguments.
pub fn load_settings(
args: CmdConfigOptions,
) -> Result<Settings, Box<dyn std::error::Error + Send + Sync>> {
let mut settings: Settings = load_config(CONFIG_FILE_NAME, Some(args))
.map_err(|e| {
format!(
"Failed to load required configuration settings with error: {e}. See --help for more details."
"Failed to load required configuration settings due to error: {e}. See --help for more details."
)
})?;

println!("after config: {:?}", settings);
debug!("settings config: {:?}", settings);

if settings.chariott_uri.is_some() {
// Get version of the service for Chariott registration if not defined.
Expand Down

0 comments on commit 6c40e8a

Please sign in to comment.