diff --git a/piker/brokers/questrade.py b/piker/brokers/questrade.py index f3708d3f..62fd1773 100644 --- a/piker/brokers/questrade.py +++ b/piker/brokers/questrade.py @@ -1134,7 +1134,7 @@ async def stream_quotes( loglevel: str = None, # feed_type: str = 'stock', ) -> 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) async with get_cached_client('questrade') as client: diff --git a/piker/cli/__init__.py b/piker/cli/__init__.py index 03dd87ae..b43f52b1 100644 --- a/piker/cli/__init__.py +++ b/piker/cli/__init__.py @@ -6,7 +6,7 @@ import os import click 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 @@ -72,8 +72,36 @@ def cli(ctx, broker, loglevel, tl, configdir): 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: from ..data import marketstore as _ + from ..data import cli as _ from ..brokers import cli as _ # noqa from ..ui import cli as _ # noqa from ..watchlists import cli as _ # noqa