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

Initialize signer lazily #7

Merged
merged 2 commits into from
Dec 10, 2024

Conversation

lucaong
Copy link
Contributor

@lucaong lucaong commented Nov 25, 2024

By initializing the signer lazily, only when used the first time, the check for missing secret_key and principal_id is also postponed until an actual API call to Azure is made.

This makes it possible to load the Rails environment without setting the Azure Storage credentials in environments that do not need to connect to Azure. For example, a build step that precompiles assets needs to load the environments, but usually does not need Azure Storage. Before this change, one would still have to set some (possibly fake) secret_key or principal_id in such build step, while with this change those can be omitted in any environment in which no real calls to the Azure API will be made.

By initializing the signer lazily, only when used the first time, we
also postpone the check for missing `secret_key` and `principal_id`.

This makes it possible to load the Rails environment without setting the
Azure Storage credentials in environments that do not need to connect to
Azure. For example, a build step that precompiles assets needs to load
the environments, but usually does not need Azure Storage. Before this
change, one would still have to set some (possibly fake) `secret_key` or
`principal_id` in such build step, while with this change those can be
omitted in any situation in which no real calls to the Azure API will be
made.
@JoeDupuis
Copy link
Member

JoeDupuis commented Dec 7, 2024

The last two weeks were pretty buzy, I'll review soon.
I want to add some tests and perhaps an option to lazy load instead of defaulting to lazy loading.
Initially, I was loading on startup intentionally so that no Rails servers could start and pass a health check (potentially killing the previous deployment) and then fail on uploads.

I didn't consider asset precompilation. I think a lazy option would make sense.

@JoeDupuis JoeDupuis force-pushed the lazy-signer-instantiation branch from 8e4ff6e to 4d5b925 Compare December 10, 2024 00:32
Copy link
Member

@JoeDupuis JoeDupuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gated this behind the lazy option and added a test.

Thank you for the contribution! I'll cut a new release soon.

@JoeDupuis JoeDupuis merged commit 7a672f3 into testdouble:main Dec 10, 2024
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.

2 participants