Skip to content

Conversation

@zzstoatzz
Copy link
Collaborator

Summary

Converts the Foreman LoopService to a docket perpetual function (monitor_worker_health).

Foreman monitors workers and marks stale resources as offline/not ready:

  • Marks workers without recent heartbeat as offline
  • Marks work pools without online workers as not ready
  • Marks deployments with old last_polled time as not ready
  • Marks work queues with old last_polled time as not ready

Unlike other service conversions (cancellation_cleanup, pause_expirations, late_runs, repossessor), foreman doesn't use the find-and-flood pattern. All operations run within a single perpetual function since the work is lightweight and doesn't benefit from task delegation.

Changes

  • Convert Foreman class to monitor_worker_health() perpetual function
  • Extract helper functions _mark_online_workers_without_recent_heartbeat_as_offline(), _mark_work_pools_as_not_ready(), _mark_deployments_as_not_ready(), _mark_work_queues_as_not_ready()
  • Remove Foreman from base.py service registry
  • Update tests to call monitor_worker_health() directly instead of Foreman().run_once()
  • Add foreman registration test to test_perpetual_services.py

Part of the staged rollout converting LoopService background services to docket perpetual functions:

Test plan

  • All existing foreman tests pass (16 tests)
  • Perpetual service registration test passes
  • Service subset tests pass

🤖 Generated with Claude Code

convert the Foreman LoopService to a docket perpetual function.
foreman monitors workers and marks stale resources as offline/not ready:
- marks workers without recent heartbeat as offline
- marks work pools without online workers as not ready
- marks deployments with old last_polled time as not ready
- marks work queues with old last_polled time as not ready

unlike other conversions, foreman doesn't use find-and-flood pattern
since all operations run in a single perpetual function.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 11, 2025

CodSpeed Performance Report

Merging #19741 will not alter performance

Comparing docket-foreman (853c032) with main (46570d2)

Summary

✅ 2 untouched

Foreman is now a perpetual function, so it no longer appears in Service.all_services().
Update the test to expect Scheduler instead.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copy link
Member

@desertaxle desertaxle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@zzstoatzz zzstoatzz merged commit cb1adb7 into main Dec 12, 2025
89 of 90 checks passed
@zzstoatzz zzstoatzz deleted the docket-foreman branch December 12, 2025 00:01
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.

3 participants