Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Support default value for optional environment variables #56

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ameykusurkar
Copy link
Contributor

@ameykusurkar ameykusurkar commented Jul 12, 2024

Prius helps us ensure that our application always boots with the
required state. However in large applications with multiple contributors,
this can cause a configuration error in an unrelated component to break
the entire application.

Providing a default value allows contributors to safely introduce new
configuration without worrying if the application breaks. For example:

Prius.get(:my_worker_pool, type: int, required: false, default: 0)

It also means that boolean flags that are optional can be made to have a
default value of true or false, rather than nil.

Note: This change does not allow you to specify a default value for
required config, for obvious reasons.

Split the logic for loading a value from parsing the value, that way we
only need to check if the env var is required in one place.
Prius helps us ensure that our application always boots with the
required state. However in large applications with multiple contributors,
this can cause a configuration error in an unrelated component to break
the entire application.

Providing a default value allows contributors to safely introduce new
configuration without worrying if the application breaks. For example:
```ruby
Prius.get(:my_worker_pool, type: int, required: false, default: 0)
```

It also means that boolean flags that are optional can be made to have a
default value of `false` rather than `nil`.

Note: This change _does not_ allow you to specify a default value for
required config, for obvious reasons.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant