Skip to content

feat: cache distributed config fetches - #149

Open
tionis wants to merge 3 commits into
encodeous:mainfrom
tionis:handle-http-caching
Open

feat: cache distributed config fetches#149
tionis wants to merge 3 commits into
encodeous:mainfrom
tionis:handle-http-caching

Conversation

@tionis

@tionis tionis commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

I noticed that Nylon currently doesn’t use HTTP caching when fetching distributed configuration, and its polling interval isn’t configurable. This can put more load on the central HTTP server than necessary. (And cost me a few cent more in bandwidth from my CDN provider).

This PR adds standard HTTP caching—including ETag and Last-Modified revalidation—and makes the config fetch interval configurable through dist.poll_interval. Existing behavior remains unchanged by default, with polling every 10 seconds.

Copilot AI lite review requested due to automatic review settings August 13, 2026 12:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces central configuration distribution load by adding standard HTTP caching semantics (freshness + conditional revalidation) for HTTP-based repos, and by making the distribution polling cadence configurable via dist.poll_interval (default remains 10s).

Changes:

  • Add dist.poll_interval to central config, validate it, and document it (docs + sample config).
  • Introduce a persistent configFetcher that reuses HTTP connections and implements ETag / Last-Modified conditional requests plus Cache-Control/Expires freshness handling.
  • Switch the config distribution scheduler to a dynamic repeat loop so the poll interval can update after live config reloads; add unit tests for caching and YAML duration parsing.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
state/validation.go Validates dist.poll_interval is present and positive when configured.
state/config.go Adds PollInterval *time.Duration to DistributionCfg with YAML mapping.
state/config_distribution_test.go Tests YAML unmarshalling of poll_interval and validator enforcement.
example/sample-central.yaml Documents and demonstrates poll_interval usage in sample config.
docs/reference/config.mdx Updates config reference docs to include poll_interval and HTTP caching behavior.
docs/guides/config-distribution.mdx Expands distribution guide with poll_interval and caching details.
core/nylon.go Adds configFetcher + configPollDelay fields, initializes fetcher, and wires cleanup.
core/nylon_scheduler.go Adds RepeatTaskDynamic to support runtime-adjustable polling intervals.
core/nylon_distribution.go Implements caching-aware HTTP fetching and integrates it into periodic config polling.
core/nylon_distribution_test.go Adds tests for ETag/Last-Modified behavior, freshness handling, and poll delay updates.
core/nylon_apply.go Updates poll delay when a new central config is successfully applied.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread core/nylon_distribution.go Outdated
Comment thread core/nylon_scheduler.go
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