feat: refactor token verifier factory - #1365
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! |
4b35ed7 to
c9940de
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces configurable resilience policies for indexer “resilient readers” (rate limiting / bulkhead / circuit breaker / timeouts) via top-level indexer config, and refactors the token verifier binary to use a shared service-factory implementation in cmd/verifier.
Changes:
- Add
[Resilience]to indexer config and plumb the resulting settings through indexer reader construction (REST + Aggregator). - Introduce
readers.NewResilienceConfig(config.ResilienceConfig)plus unit tests to default/override resilience settings. - Refactor
cmd/verifier/tokento use a newcmd/verifier/tokenfactory.goservice factory (moving the previous in-main implementation).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| indexer/pkg/readers/rest_reader.go | Accept resilience policies via RestReaderConfig and pass through to resilient wrapper |
| indexer/pkg/readers/rest_reader_test.go | Update REST reader tests to pass resilience config explicitly |
| indexer/pkg/readers/resilient_reader.go | Add config-to-reader resilience translation helper (NewResilienceConfig) |
| indexer/pkg/readers/resilient_reader_test.go | New unit tests for resilience translation/defaulting behavior |
| indexer/pkg/readers/aggregator_reader.go | Extend aggregator reader factory to accept resilience config and set discovery handlers |
| indexer/pkg/config/config.go | Add Config.Resilience and define TOML-backed ResilienceConfig |
| indexer/config.example.toml | Document example [Resilience] values |
| indexer/cmd/replay/main.go | Thread resilience config into verifier/discovery reader creation |
| indexer/cmd/main.go | Thread resilience config into verifier/discovery reader creation |
| cmd/verifier/tokenfactory.go | New shared token-verifier ServiceFactory implementation |
| cmd/verifier/token/main.go | Switch token verifier binary to use the new shared ServiceFactory |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Code coverage report:
Files added (in
|
| type tokenFactory struct { | ||
| bootstrap.ServiceFactory | ||
|
|
||
| coordinators []*verifier.Coordinator | ||
| httpServer *http.Server | ||
| lggr logger.Logger | ||
| } | ||
|
|
||
| // NewTokenVerifierServiceFactory creates a new ServiceFactory for the token verifier service. | ||
| // The factory loads the verifier secrets file itself in Start, so each chain-family binary's | ||
| // main.go stays free of secrets-loading boilerplate. | ||
| func NewTokenVerifierServiceFactory() bootstrap.ServiceFactory { | ||
| return &tokenFactory{} | ||
| } | ||
|
|
||
| // Stop tries to stop all services gracefully. | ||
| func (tvf *tokenFactory) Stop(_ context.Context) error { |
There was a problem hiding this comment.
tiny nit: tvf let's sync naming convention :) looks like it used to be tokenVerifierFactory and renamed to tokenFactory
Export the token verifier factory to support standalone mode token verifier in chain family repo.