Add `services` cmd for monitoring actors
parent
65fb92eaff
commit
81fb327fe1
|
@ -1134,7 +1134,7 @@ async def stream_quotes(
|
||||||
loglevel: str = None,
|
loglevel: str = None,
|
||||||
# feed_type: str = 'stock',
|
# feed_type: str = 'stock',
|
||||||
) -> AsyncGenerator[str, Dict[str, Any]]:
|
) -> AsyncGenerator[str, Dict[str, Any]]:
|
||||||
# XXX: why do we need this again?
|
# XXX: required to propagate ``tractor`` loglevel to piker logging
|
||||||
get_console_log(tractor.current_actor().loglevel)
|
get_console_log(tractor.current_actor().loglevel)
|
||||||
|
|
||||||
async with get_cached_client('questrade') as client:
|
async with get_cached_client('questrade') as client:
|
||||||
|
|
|
@ -6,7 +6,7 @@ import os
|
||||||
import click
|
import click
|
||||||
import tractor
|
import tractor
|
||||||
|
|
||||||
from ..log import get_console_log, get_logger
|
from ..log import get_console_log, get_logger, colorize_json
|
||||||
from ..brokers import get_brokermod, config
|
from ..brokers import get_brokermod, config
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,8 +72,36 @@ def cli(ctx, broker, loglevel, tl, configdir):
|
||||||
ctx.obj.update({'tractorloglevel': loglevel})
|
ctx.obj.update({'tractorloglevel': loglevel})
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command()
|
||||||
|
@click.option('--tl', is_flag=True, help='Enable tractor logging')
|
||||||
|
@click.argument('names', nargs=-1, required=False)
|
||||||
|
@click.pass_obj
|
||||||
|
def services(config, tl, names):
|
||||||
|
|
||||||
|
async def list_services():
|
||||||
|
async with tractor.get_arbiter(
|
||||||
|
*tractor.current_actor()._arb_addr
|
||||||
|
) as portal:
|
||||||
|
registry = await portal.run('self', 'get_registry')
|
||||||
|
json_d = {}
|
||||||
|
for uid, socket in registry.items():
|
||||||
|
name, uuid = uid
|
||||||
|
host, port = socket
|
||||||
|
json_d[f'{name}.{uuid}'] = f'{host}:{port}'
|
||||||
|
click.echo(
|
||||||
|
f"Available `piker` services:\n{colorize_json(json_d)}"
|
||||||
|
)
|
||||||
|
|
||||||
|
tractor.run(
|
||||||
|
list_services,
|
||||||
|
name='service_query',
|
||||||
|
loglevel=config['loglevel'] if tl else None,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _load_clis() -> None:
|
def _load_clis() -> None:
|
||||||
from ..data import marketstore as _
|
from ..data import marketstore as _
|
||||||
|
from ..data import cli as _
|
||||||
from ..brokers import cli as _ # noqa
|
from ..brokers import cli as _ # noqa
|
||||||
from ..ui import cli as _ # noqa
|
from ..ui import cli as _ # noqa
|
||||||
from ..watchlists import cli as _ # noqa
|
from ..watchlists import cli as _ # noqa
|
||||||
|
|
Loading…
Reference in New Issue