Skip to content

Commit

Permalink
Config::from_env never returns an error.
Browse files Browse the repository at this point in the history
We don't need to return Result because the function either panics or returns the Ok value.

Signed-off-by: David Calavera <david.calavera@gmail.com>
  • Loading branch information
calavera committed Dec 13, 2023
1 parent 2a2ae8b commit 1d2bb6b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lambda-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ type RefConfig = Arc<Config>;

impl Config {
/// Attempts to read configuration from environment variables.
pub fn from_env() -> Result<Self, Error> {
let conf = Config {
pub fn from_env() -> Self {
Config {
function_name: env::var("AWS_LAMBDA_FUNCTION_NAME").expect("Missing AWS_LAMBDA_FUNCTION_NAME env var"),
memory: env::var("AWS_LAMBDA_FUNCTION_MEMORY_SIZE")
.expect("Missing AWS_LAMBDA_FUNCTION_MEMORY_SIZE env var")
Expand All @@ -74,8 +74,7 @@ impl Config {
version: env::var("AWS_LAMBDA_FUNCTION_VERSION").expect("Missing AWS_LAMBDA_FUNCTION_VERSION env var"),
log_stream: env::var("AWS_LAMBDA_LOG_STREAM_NAME").unwrap_or_default(),
log_group: env::var("AWS_LAMBDA_LOG_GROUP_NAME").unwrap_or_default(),
};
Ok(conf)
}
}
}

Expand Down Expand Up @@ -254,7 +253,7 @@ where
E: Into<Error> + Send + Debug,
{
trace!("Loading config from env");
let config = Config::from_env()?;
let config = Config::from_env();
let client = Client::builder().build().expect("Unable to create a runtime client");
let runtime = Runtime {
client,
Expand Down

0 comments on commit 1d2bb6b

Please sign in to comment.