8000 feat(actuator): add pause scheduling stream listener and local cache by andrzejfudro · Pull Request #912 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

feat(actuator): add pause scheduling stream listener and local cache - #912

Merged
andrzejfudro merged 2 commits into
mainfrom
feat/pause-scheduling-actuator-listener
Sep 18, 2026
Merged

andrzejfudro merged 2 commits into
mainfrom
feat/pause-scheduling-actuator-listener

Conversation

@andrzejfudro
@andrzejfudro andrzejfudro commented Sep 17, 2026 •
Copy link
Copy Markdown
Collaborator

Author note:

This PR operates on the fake implementation of the broadcast instead of real redis-streams-based one. This still remains mostly untested but it is hidden behind the feature flag and will be fully verified once I connect all the parts together.

Summary

Implements the background stream listener worker and thread-safe local cache in Actuator for the Pause Scheduling feature.

Key Changes

  • Local Cache (cmd/actuator/pausescheduling/cache.go): Thread-safe in-memory cache exposing an atomic State() point-in-time view (IsPaused, UpdatedAt) and anti-thrashing Update().
  • Stream Listener (cmd/actuator/pausescheduling/listener.go): Background worker subscribing to xmc-pause-stream. Features synchronous cold-start seeding (Init) before task queue worker starts, and backoff retry resync (resyncOnReconnect) on stream disconnections.
  • Server Wiring (cmd/actuator/prod.go): Initializes pausescheduling.Cache and starts pausescheduling.Listener during NewProd when FeatureFlags.PauseSchedulingEnabled is active.
  • Broadcast Test Double (internal/broadcast/fake.go): Added LatestOffset implementation to FakeClient.

Verification

  • bazel test //cmd/actuator:actuator_test //cmd/actuator/pausescheduling:pausescheduling_test //internal/broadcast:broadcast_test (Passed)
  • bazel test --@io_bazel_rules_go//go/config:race //cmd/actuator/pausescheduling:pausescheduling_test (Passed with 0 races)
  • ./.githooks/pre-commit

TAG=agy
CONV=59b60431-f41c-4f8a-a0e7-8653629dfe3e

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a new pause scheduling mechanism for the Actuator, including a thread-safe in-memory cache to track the pause state and a background listener that synchronizes this state using Spanner and Redis broadcast streams. The review feedback highlights critical safety issues, specifically potential nil pointer dereference panics when querying the pause state repository, and a logical flaw in the cache's timestamp fallback mechanism that could lead to legitimate updates being incorrectly ignored.

Comment thread cmd/actuator/pausescheduling/cache.go Resolved
Implement background stream listener worker subscribing to Redis broadcast
stream and thread-safe local atomic cache for the Pause Scheduling feature.
Includes cold-start state synchronization, reconnection resync logic, and
unit test coverage.

TAG=agy
CONV=59b60431-f41c-4f8a-a0e7-8653629dfe3e
@andrzejfudro
andrzejfudro force-pushed the feat/pause-scheduling-actuator-listener branch from 58e2798 to f0c6a86 Compare September 17, 2026 13:31
@andrzejfudro
andrzejfudro marked this pull request as ready for review September 17, 2026 13:33
janzak-dev
janzak-dev previously approved these changes Sep 17, 2026
Comment thread cmd/actuator/pausescheduling/cache.go Resolved
…nabled flag

Address review comments by:
1. Updating Cache.Update to accept a newState State struct.
2. Removing redundant Enabled boolean from Params and Listener, as the
   feature flag is already enforced at the caller site in prod.go.

TAG=agy
CONV=59b60431-f41c-4f8a-a0e7-8653629dfe3e
@andrzejfudro
andrzejfudro force-pushed the feat/pause-scheduling-actuator-listener branch from 2beba01 to 15adb17 Compare September 17, 2026 15:19
@andrzejfudro
andrzejfudro added this pull request to the merge queue Sep 18, 2026
Merged via the queue into main with commit 2254530 Sep 18, 2026
11 checks passed
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

0