Polling interval - #8
Open
Dimariqe wants to merge 2 commits into
Open
Conversation
Introduces the CW_CLIENT_POLLING_INTERVAL environment variable to enable periodic polling for certificate updates as an alternative to server push notifications. Adds parsing for duration strings (e.g., 1d, 5h, 30m), updates configuration and scheduling logic, and implements a background polling job for fetching certificates.
Changed the git clone URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for polling the server for new certificates at a configurable interval, as an alternative to server push notifications. It introduces a new environment variable to control polling, implements duration parsing, updates configuration, and adds background job scheduling for polling.
Polling support for certificate updates:
CW_CLIENT_POLLING_INTERVALenvironment variable, allowing users to specify how frequently the client should poll the server for new certificates (e.g., "1d", "5h", "30m"). If not set, polling is disabled and server push notifications are used instead. (pkg/main/config.go,[[1]](https://github.com/gregtwallace/certwarden-client/pull/8/files#diff-27bb5023dd4d98c7ac3f60d9c3b3a37e9ce4a6beba4bd9ce45647a44d236d01dR47-R48),[[2]](https://github.com/gregtwallace/certwarden-client/pull/8/files#diff-27bb5023dd4d98c7ac3f60d9c3b3a37e9ce4a6beba4bd9ce45647a44d236d01dR156),[[3]](https://github.com/gregtwallace/certwarden-client/pull/8/files#diff-27bb5023dd4d98c7ac3f60d9c3b3a37e9ce4a6beba4bd9ce45647a44d236d01dR211-R226))parseDurationStringfunction to parse duration strings with support for days, hours, minutes, and seconds (e.g., "1d", "1h30m"). (pkg/main/config_time_parse.go,[pkg/main/config_time_parse.goR103-R128](https://github.com/gregtwallace/certwarden-client/pull/8/files#diff-443cdb4932b63113751948cc6207da70f81d9e0af7d6d746af116fb13f763ad0R103-R128))Background job scheduling for polling:
scheduleJobPollingFetchmethod, which starts a background job per certificate that polls the server at the configured interval to check for updates. This job handles cancellation, error logging, and ensures certificate files are updated as needed. (pkg/main/update_schedule.go,[pkg/main/update_schedule.goR200-R248](https://github.com/gregtwallace/certwarden-client/pull/8/files#diff-961ba96852948a1bde8e27197a7c2b261239693a7a266d8310047141d6d4b39cR200-R248))mainfunction to start the polling job for each certificate if polling is enabled. (pkg/main/main.go,[pkg/main/main.goR50-R54](https://github.com/gregtwallace/certwarden-client/pull/8/files#diff-d7a2d96fc0a53ace9214a64c52a292858dcb6abbda3638fccec29d65c2d1f3d4R50-R54))