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