Move ServiceMngr to tractor.hilevel #28

Open
goodboy wants to merge 12 commits from service_mng_to_tractor into stop_is_oec

Been in the works for a while to factor this out of piker and into tractor core so we can better test and extend it for general purpose use from a new .hilevel (apis) subpkg B)

This patch-set should be disjoint from other recent PRs and should eventually include a pinned uv dep to the equivalent dev-branch (or 🙏 maybe even alpha release) in the tractor repo..

Been in the works for a while to factor this out of `piker` and into `tractor` core so we can better test and extend it for general purpose use from a new `.hilevel` (apis) subpkg B) This patch-set should be disjoint from other recent PRs and should eventually include a pinned `uv` dep to the equivalent dev-branch (or 🙏 maybe even alpha release) in the `tractor` repo..
goodboy added 5 commits 2025-02-11 23:52:45 +00:00
41b0584588 Prep service mngr for move to `tractor.hilevel`
Given it's a fairly simple yet useful abstraction, it makes sense to
offer this sub-sys alongside the core `tractor` runtime lib.

Without going into extreme detail on the impl changes (it'll come in
the commit that moves to the other repo) here is the high level summary:
------ - ------
- rename `Services` -> `ServiceMngr` and use an factory `@acm`
  to guarantee a single-instance-per-actor using a niche approach for a
  singleton object using a default keyword-arg B)
  - the mod level `open_service_mngr()` and `get_service_mngr()` are the
    new allocation/access API.
- add a `ServiceMngr.start_service()` method which does the work of both
  spawning a new subactor (for the daemon) and uses its portal to start
  the mngr side supervision task.
- open actor/task nurseries inside the `@acm` allocator.

Adjust other dependent subsystems to match:
------ - ------
- use `open_service_mngr()` when first allocated in `open_pikerd()`.
- use `get_service_mngr()` instead of importing the class ref inside
  `.service.maybe_spawn_daemon()`, `.brokers._daemon.spawn_brokerd()`
  and `.data._sampling.spawn_samplerd()` using a `partial` to pack in
  the endpoint ctx kwargs (unpacked inside `.start_service()` XD).
77703f2201 Drop `.cancel_actor()` from `maybe_spawn_daemon()`
Since `tractor`'s new and improved inter-actor cancellation semantics
are much more pedantic, AND bc we use the `ServiceMngr` for spawning
service actors on-demand, the caller of `maybe_spawn_daemon()` should
NEVER conduct a so called "out of band" `Actor`-runtime cancel request
since this is precisely the job of our `ServiceMngr` XD

Add a super in depth note explaining the underlying issue and adding
a todo list of how we should prolly augment `tractor` to make such cases
easier to grok and fix in the future!
4d29722794 More service-mngr clarity notes
Nothing changing functionally here just adding more `tractor`
operational notes, tips for debug tooling and typing fixes B)

Of particular note is adding further details about the reason we do not
need to call `Context.cancel()` inside the `finally:` block of
`.open_context_in_task()` thanks to `tractor`'s new and improved
inter-actor cancellation semantics Bo
cd4fd02e5c Official service-mngr to `tractor.hilevel` move
Such that we maintain that subsys in the actor-runtime repo (with
hopefully an extensive test suite XD).

Port deats,
- rewrite `open_service_mngr()` as a thin wrapper that delegates into
  the new `tractor.hilevel.open_service_mngr()` but with maintenance of
  the `Services` class-singleton for now.
- port `.service._daemon` usage to the new
  `ServiceMngr.start_service_ctx()` a rename from
  `.start_service_task()` which is now likely destined for the soon
  supported `tractor.trionics.TaskMngr` nursery extension.
- ref the new `ServiceMngr.an: ActorNursery` instance var name.

Other,
- always enable the `tractor.pause_from_sync()` support via `greenback`
  whenever `debug_mode` is set at `pikerd` init.
goodboy force-pushed service_mng_to_tractor from cd4fd02e5c to adc0cda1e3 2025-02-12 13:08:15 +00:00 Compare
goodboy changed title from Move `ServiceMngr` to `tractor.hilevel` to Move `ServiceMngr` to `tractor.hilevel` 2025-02-12 13:08:29 +00:00
goodboy changed target branch from go_httpx to gitea_feats 2025-02-12 13:08:29 +00:00
goodboy force-pushed service_mng_to_tractor from adc0cda1e3 to a92432df5e 2025-02-17 19:05:17 +00:00 Compare
goodboy added 1 commit 2025-02-17 19:38:49 +00:00
goodboy force-pushed service_mng_to_tractor from 333a53f30c to 90bdac5f72 2025-02-17 19:58:01 +00:00 Compare
goodboy force-pushed service_mng_to_tractor from 90bdac5f72 to 01cbd0a775 2025-02-20 17:11:16 +00:00 Compare
goodboy changed title from Move `ServiceMngr` to `tractor.hilevel` to Move `ServiceMngr` to `tractor.hilevel` 2025-02-20 17:11:32 +00:00
goodboy changed target branch from gitea_feats to stop_is_oec 2025-02-20 17:11:32 +00:00
goodboy force-pushed service_mng_to_tractor from 01cbd0a775 to b9e904666b 2025-02-21 21:36:59 +00:00 Compare
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b service_mng_to_tractor stop_is_oec
git pull origin service_mng_to_tractor

Step 2:

Merge the changes and update on Gitea.
git checkout stop_is_oec
git merge --no-ff service_mng_to_tractor
git push origin stop_is_oec
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: pikers/piker#28
There is no content yet.