Support passing `tractor` "actor runtime vars" down the runtime

service_subpkg
Tyler Goodlet 2023-03-09 14:09:12 -05:00
parent 2014019b06
commit aa36abf36e
1 changed files with 10 additions and 0 deletions

View File

@ -74,6 +74,7 @@ async def open_piker_runtime(
# and spawn the service tree distributed per that.
start_method: str = 'trio',
tractor_runtime_overrides: dict | None = None,
**tractor_kwargs,
) -> tuple[
@ -93,6 +94,8 @@ async def open_piker_runtime(
actor = tractor.current_actor().uid
except tractor._exceptions.NoRuntime:
tractor._state._runtime_vars[
'piker_vars'] = tractor_runtime_overrides
registry_addr = registry_addr or _default_reg_addr
@ -152,6 +155,8 @@ async def open_pikerd(
tsdb: bool = False,
es: bool = False,
**kwargs,
) -> Services:
'''
Start a root piker daemon with an indefinite lifetime.
@ -173,6 +178,8 @@ async def open_pikerd(
debug_mode=debug_mode,
registry_addr=registry_addr,
**kwargs,
) as (root_actor, reg_addr),
tractor.open_nursery() as actor_nursery,
trio.open_nursery() as service_nursery,
@ -297,6 +304,7 @@ async def maybe_open_pikerd(
loglevel=loglevel,
**kwargs,
) as _,
tractor.find_actor(
_root_dname,
arbiter_sockaddr=registry_addr,
@ -319,6 +327,8 @@ async def maybe_open_pikerd(
tsdb=tsdb,
es=es,
**kwargs,
) as service_manager:
# in the case where we're starting up the
# tractor-piker runtime stack in **this** process