Fix `TIPC` two-host service example

A registrar root does not register itself in its own actor-name
registry, so host B could never discover the advertised `host_a`.
Boot that service as a child actor under the `TIPC` registrar
instead.

Import and pass the enabled `echo` callable to `.open_context()`;
the prior module-path string could not produce a `NamespacePath`.

Review: PR #493 (copilot-pull-request-reviewer[bot],goodboy)
https://github.com/goodboy/tractor/pull/493

(this patch was generated in some part by `opencode` using
`gpt-5.6-sol` (`openai`))
wkt/pr493_review
Gud Boi 2026-08-18 13:45:54 -04:00
parent be6f9e86d1
commit c1501a36d5
2 changed files with 9 additions and 6 deletions

View File

@ -47,14 +47,16 @@ async def main() -> None:
reg: TIPCAddress = TIPCAddress.get_root()
print(f'host A publishing {reg}')
async with tractor.open_root_actor(
name='host_a',
async with tractor.open_nursery(
enable_transports=['tipc'],
registry_addrs=[reg.unwrap()],
enable_modules=[__name__],
):
) as an:
await an.start_actor(
'host_a',
enable_modules=[__name__],
)
print(
'registrar up — `tipc nametable show` on EITHER host\n'
'host_a up — `tipc nametable show` on EITHER host\n'
'should now list this service. ctrl-c to stop.'
)
await trio.sleep_forever()

View File

@ -16,6 +16,7 @@ from __future__ import annotations
import trio
import tractor
from host_a_srv import echo
from tractor.ipc._tipc import (
TIPCAddress,
is_tipc_available,
@ -41,7 +42,7 @@ async def main() -> None:
async with (
ptl.open_context(
'host_a_srv:echo',
echo,
) as (ctx, _),
ctx.open_stream() as stream,
):