Skip to content

Refactor poller for concurrency and cleaner architecture#5

Closed
arvarik wants to merge 2 commits intomainfrom
refactor-poller-and-auth-14520959867178010951
Closed

Refactor poller for concurrency and cleaner architecture#5
arvarik wants to merge 2 commits intomainfrom
refactor-poller-and-auth-14520959867178010951

Conversation

@arvarik
Copy link
Owner

@arvarik arvarik commented Feb 23, 2026

This change refactors the eero-stats daemon to improve robustness and testability.

Key changes:

  1. Concurrency: The Poller now runs each polling tier in a separate goroutine. This prevents a slow poll in one tier from blocking others and ensures consistent scheduling.
  2. Interfaces: Introduced EeroClient and MetricWriter interfaces to decouple the Poller from concrete implementations.
  3. Configuration: Added EERO_SESSION_PATH configuration option to allow customizing the session file location, making the application more flexible (e.g., for non-Docker environments).
  4. Testing: Added unit tests for the Poller logic, 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

- 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>
@google-labs-jules
Copy link

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

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>
@arvarik arvarik closed this Feb 23, 2026
@arvarik arvarik deleted the refactor-poller-and-auth-14520959867178010951 branch February 23, 2026 05:57
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