Use new `tractor.query_actor()` for service checking
parent
531989a9e5
commit
c874b6aca0
|
@ -303,16 +303,15 @@ class Brokerd:
|
||||||
@acm
|
@acm
|
||||||
async def find_service(
|
async def find_service(
|
||||||
service_name: str,
|
service_name: str,
|
||||||
|
) -> Optional[tractor.Portal]:
|
||||||
|
|
||||||
) -> tractor.Portal:
|
log.info(f'Scanning for service `{service_name}`')
|
||||||
|
|
||||||
log.info(f'Scanning for existing {service_name}')
|
|
||||||
# attach to existing daemon by name if possible
|
# attach to existing daemon by name if possible
|
||||||
async with tractor.find_actor(
|
async with tractor.find_actor(
|
||||||
service_name,
|
service_name,
|
||||||
arbiter_sockaddr=_registry_addr,
|
arbiter_sockaddr=_registry_addr,
|
||||||
) as portal:
|
) as maybe_portal:
|
||||||
yield portal
|
yield maybe_portal
|
||||||
|
|
||||||
|
|
||||||
async def check_for_service(
|
async def check_for_service(
|
||||||
|
@ -323,8 +322,11 @@ async def check_for_service(
|
||||||
Service daemon "liveness" predicate.
|
Service daemon "liveness" predicate.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
async with find_service(service_name) as portal:
|
async with tractor.query_actor(
|
||||||
return portal is not None
|
service_name,
|
||||||
|
arbiter_sockaddr=_registry_addr,
|
||||||
|
) as sockaddr:
|
||||||
|
return sockaddr
|
||||||
|
|
||||||
|
|
||||||
@acm
|
@acm
|
||||||
|
|
Loading…
Reference in New Issue