Skip to content

Polling interval - #8

Open
Dimariqe wants to merge 2 commits into
gregtwallace:mainfrom
Dimariqe:polling-interval
Open

Polling interval#8
Dimariqe wants to merge 2 commits into
gregtwallace:mainfrom
Dimariqe:polling-interval

Conversation

@Dimariqe

Copy link
Copy Markdown

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:

  • Added support for the CW_CLIENT_POLLING_INTERVAL environment 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))
  • Implemented the parseDurationString function 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:

  • Added the scheduleJobPollingFetch method, 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))
  • Updated the main function 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))

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.
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