feat: support resilient reader config for indexer and add retry policy - #1364
feat: support resilient reader config for indexer and add retry policy#1364huangzhen1997 wants to merge 6 commits into
Conversation
|
👋 huangzhen1997, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
There was a problem hiding this comment.
Pull request overview
This PR makes the indexer’s resilient reader policies configurable via TOML, so rate limiting / bulkhead / circuit breaker / timeout parameters are no longer hardcoded and can be tuned to mitigate downstream rate limiting.
Changes:
- Adds
[Resilience]configuration to the indexer config model and example TOML. - Introduces a
readers.NewResilienceConfig(config.ResilienceConfig)adapter that applies defaults for zero-valued config fields. - Threads the resilience configuration through reader construction (REST + Aggregator) and adds tests for the new adapter.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| indexer/pkg/readers/rest_reader.go | Adds resilience config to RestReaderConfig and passes it into NewResilientReader. |
| indexer/pkg/readers/rest_reader_test.go | Updates REST reader tests to provide a resilience config. |
| indexer/pkg/readers/resilient_reader.go | Adds adapter to convert indexer config resilience settings into reader resilience config with defaults. |
| indexer/pkg/readers/resilient_reader_test.go | Adds unit tests for NewResilienceConfig defaulting/overrides behavior. |
| indexer/pkg/readers/aggregator_reader.go | Extends constructor signature to accept resilience config and wires aggregator-specific handlers. |
| indexer/pkg/config/config.go | Adds Resilience and ResilienceConfig to the indexer configuration model. |
| indexer/config.example.toml | Documents the new [Resilience] TOML block and its default values. |
| indexer/cmd/replay/main.go | Passes configured resilience settings into reader creation in replay mode. |
| indexer/cmd/main.go | Passes configured resilience settings into reader creation in normal indexer mode. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… jh/resilient-reader-config
d71ce3f to
0a85110
Compare
|
Code coverage report:
|
There was a problem hiding this comment.
🟡 Changes recommended
A documented setting has no runtime effect, retry delays lack validation, and the retry test does not exercise retries.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 3
- Review effort level: Balanced
| // CircuitBreakerTimeout is the timeout for circuit breaker operations. | ||
| // 0 uses the default (1s). | ||
| CircuitBreakerTimeout common.Duration `toml:"CircuitBreakerTimeout"` |
| // RetryDelay is the initial delay between retries, using exponential backoff. | ||
| // 0 uses the default (1s). | ||
| RetryDelay common.Duration `toml:"RetryDelay"` | ||
| // RetryMaxDelay is the maximum delay between retries. | ||
| // 0 uses the default (10s). | ||
| RetryMaxDelay common.Duration `toml:"RetryMaxDelay"` |
| start := time.Now() | ||
| resp2, err := rr.ReadCCVData(ctx) | ||
| elapsed := time.Since(start) | ||
| require.NoError(t, err) |
Encountered rate limiting issue value of the resilient reader, and it's never configurable, it always using this hardcoded default value.