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

feat: add support for lazy refresh strategy #337

Merged
merged 3 commits into from
Jun 25, 2024
Merged

Conversation

jackwotherspoon
Copy link
Collaborator

Add refresh_strategy argument to Connector() that allows setting
the strategy to "lazy" to use a lazy refresh strategy.

When creating a Connector via Connector(refresh_strategy="lazy"),
the connection info and ephemeral certificate will be refreshed only
when the cache certificate has expired. No background tasks run
periodically with this option, making it ideal for use in serverless
environments such as Cloud Run, Cloud Functions, etc, where the
CPU may be throttled.

Usage example:

from google.cloud.alloydb.connector import Connector

with Connector(refresh_strategy="lazy") as connector:
    # ... use connector in lazy refresh mode

Port of GoogleCloudPlatform/cloud-sql-python-connector#1093

Closes #298

@jackwotherspoon jackwotherspoon self-assigned this Jun 24, 2024
@jackwotherspoon jackwotherspoon requested a review from a team as a code owner June 24, 2024 21:06
Copy link
Member

@enocom enocom left a comment

Choose a reason for hiding this comment

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

👏 Nice!

@jackwotherspoon jackwotherspoon merged commit fbf0179 into main Jun 25, 2024
15 checks passed
@jackwotherspoon jackwotherspoon deleted the lazy-refresh branch June 25, 2024 17:09
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.

Add support for lazy certificate refresh
2 participants