Refactor poller for concurrency and cleaner architecture#5
Refactor poller for concurrency and cleaner architecture#5
Conversation
- Introduced `EeroClient` and `MetricWriter` interfaces in `internal/poller` to abstract dependencies. - Updated `Poller` to use these interfaces, enabling better testability and mocking. - Rewrote `Poller.Start` to launch each polling tier (Fast, Medium, Slow) in its own goroutine, preventing blocking and ticker drift. - Added `EeroClientAdapter` to adapt the external `eero.Client`. - Updated configuration to allow setting `EERO_SESSION_PATH` via environment variable, replacing hardcoded path check. - Updated `internal/auth` to use the configured session path. - Wired up dependencies in `cmd/eero-stats/main.go`. - Added unit tests for `Poller.Start` using mocks. - Fixed existing tests in `internal/poller/retry_test.go`. Co-authored-by: arvarik <9952627+arvarik@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
- Added `sync.Mutex` to protect shared variables `calledNetwork` and `writeCount` in `TestPoller_Start`. - This resolves a data race between the test goroutine and the concurrent polling tiers spawned by `Poller.Start`. Co-authored-by: arvarik <9952627+arvarik@users.noreply.github.com>
This change refactors the
eero-statsdaemon to improve robustness and testability.Key changes:
Pollernow runs each polling tier in a separate goroutine. This prevents a slow poll in one tier from blocking others and ensures consistent scheduling.EeroClientandMetricWriterinterfaces to decouple thePollerfrom concrete implementations.EERO_SESSION_PATHconfiguration option to allow customizing the session file location, making the application more flexible (e.g., for non-Docker environments).Pollerlogic, verifying that it correctly interacts with the Eero client and Influx writer.These changes address the issues identified during code review regarding synchronous polling blocking startup and hardcoded paths.
PR created automatically by Jules for task 14520959867178010951 started by @arvarik