Fill in label with pairs from `status` value of backend init msg
parent
488506d8b8
commit
88eccc1e15
|
@ -46,6 +46,7 @@ import numpy as np
|
|||
|
||||
from ..brokers import get_brokermod
|
||||
from .._cacheables import maybe_open_context
|
||||
from ..calc import humanize
|
||||
from ..log import get_logger, get_console_log
|
||||
from .._daemon import (
|
||||
maybe_spawn_brokerd,
|
||||
|
@ -1183,10 +1184,10 @@ class Feed:
|
|||
shm: ShmArray
|
||||
mod: ModuleType
|
||||
first_quotes: dict # symbol names to first quote dicts
|
||||
|
||||
_portal: tractor.Portal
|
||||
|
||||
stream: trio.abc.ReceiveChannel[dict[str, Any]]
|
||||
status: dict[str, Any]
|
||||
|
||||
throttle_rate: Optional[int] = None
|
||||
|
||||
_trade_stream: Optional[AsyncIterator[dict[str, Any]]] = None
|
||||
|
@ -1327,9 +1328,24 @@ async def open_feed(
|
|||
first_quotes=first_quotes,
|
||||
stream=stream,
|
||||
_portal=portal,
|
||||
status={},
|
||||
throttle_rate=tick_throttle,
|
||||
)
|
||||
|
||||
# fill out "status info" that the UI can show
|
||||
host, port = feed.portal.channel.raddr
|
||||
if host == '127.0.0.1':
|
||||
host = 'localhost'
|
||||
|
||||
feed.status.update({
|
||||
'actor_name': feed.portal.channel.uid[0],
|
||||
'host': host,
|
||||
'port': port,
|
||||
'shm': f'{humanize(feed.shm._shm.size)}',
|
||||
'throttle_rate': feed.throttle_rate,
|
||||
})
|
||||
feed.status.update(init_msg.pop('status', {}))
|
||||
|
||||
for sym, data in init_msg.items():
|
||||
si = data['symbol_info']
|
||||
fqsn = data['fqsn'] + f'.{brokername}'
|
||||
|
|
|
@ -26,7 +26,7 @@ from typing import TYPE_CHECKING
|
|||
# from PyQt5.QtCore import Qt
|
||||
|
||||
from ._style import _font, _font_small
|
||||
from ..calc import humanize
|
||||
# from ..calc import humanize
|
||||
from ._label import FormatLabel
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -49,15 +49,21 @@ def mk_feed_label(
|
|||
a feed control protocol.
|
||||
|
||||
'''
|
||||
msg = """
|
||||
status = feed.status
|
||||
assert status
|
||||
|
||||
msg = dedent("""
|
||||
actor: **{actor_name}**\n
|
||||
|_ @**{host}:{port}**\n
|
||||
|_ throttle_hz: **{throttle_rate}**\n
|
||||
|_ shm: **{shm}**\n
|
||||
"""
|
||||
""")
|
||||
|
||||
for key, val in status.items():
|
||||
if key in ('host', 'port', 'actor_name'):
|
||||
continue
|
||||
msg += f'\n|_ {key}: **{{{key}}}**\n'
|
||||
|
||||
feed_label = FormatLabel(
|
||||
fmt_str=dedent(msg),
|
||||
fmt_str=msg,
|
||||
# |_ streams: **{symbols}**\n
|
||||
font=_font.font,
|
||||
font_size=_font_small.px_size,
|
||||
|
@ -72,20 +78,6 @@ def mk_feed_label(
|
|||
# feed_label.height()
|
||||
)
|
||||
|
||||
# fill in brokerd feed info
|
||||
host, port = feed.portal.channel.raddr
|
||||
if host == '127.0.0.1':
|
||||
host = 'localhost'
|
||||
mpshm = feed.shm._shm
|
||||
shmstr = f'{humanize(mpshm.size)}'
|
||||
|
||||
feed_label.format(
|
||||
actor_name=feed.portal.channel.uid[0],
|
||||
host=host,
|
||||
port=port,
|
||||
# symbols=len(feed.symbols),
|
||||
shm=shmstr,
|
||||
throttle_rate=feed.throttle_rate,
|
||||
)
|
||||
feed_label.format(**feed.status)
|
||||
|
||||
return feed_label
|
||||
|
|
Loading…
Reference in New Issue