| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | // Package jobmgr owns runtime orchestration for discovered and dyncfg-managed jobs. |
| 4 | // |
| 5 | // Concurrency contract (must remain true unless this document is updated): |
| 6 | // |
| 7 | // - Manager.run() is the serialized owner of dyncfg state transitions: |
| 8 | // exposed configs, vnode map updates, and add/remove command application. |
| 9 | // |
| 10 | // - Discovery ingestion (runProcessConfGroups) does not mutate manager state directly. |
| 11 | // It publishes add/remove intents through channels consumed by Manager.run(). |
| 12 | // |
| 13 | // - runningJobs.items is protected by runningJobs.mux. |
| 14 | // All traversals must use runningJobs.snapshot() and execute callbacks outside the lock. |
| 15 | // No external API/job callbacks may execute while holding runningJobs.mux. |
| 16 | // |
| 17 | // - Function handlers run on framework/functions manager goroutine(s) and must avoid |
| 18 | // cross-goroutine access to manager-owned mutable maps; async work uses manager-rooted |
| 19 | // contexts and bounded worker limits where required. |
| 20 | // |
| 21 | // - Wait-for-decision gating for discovered configs is handler-owned. Manager.run() |
| 22 | // delegates wait-step orchestration to dyncfg handler and keeps dyncfg command |
| 23 | // processing progress even while waiting. |
| 24 | package jobmgr |