Skip to content

Commit

Permalink
Config::from_env never returns an error. (#754)
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 <[email protected]>
  • Loading branch information
calavera authored Dec 16, 2023
1 parent 2a2ae8b commit fb86ebc
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 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 Expand Up @@ -527,7 +526,7 @@ mod endpoint_tests {
if env::var("AWS_LAMBDA_LOG_GROUP_NAME").is_err() {
env::set_var("AWS_LAMBDA_LOG_GROUP_NAME", "test_log");
}
let config = Config::from_env().expect("Failed to read env vars");
let config = Config::from_env();

let runtime = Runtime {
client,
Expand Down

0 comments on commit fb86ebc

Please sign in to comment.