Declare per-daemon-kind backend mod groups

Prep for the `brokerd` -> (`datad` + `brokerd`) actor split
by having each (split-style) backend declare which of its
submods host which daemon-kind's eps, exactly per the
`piker.data.validate._eps` groupings; `ib` already had
`_brokerd_mods`/`_datad_mods` so extend the convention to
`kraken`, `binance` and `deribit` (and add `'api'` to ib's
datad set since both kinds need the `Client` layer).

`__enable_modules__` stays as the (deduped) union so this
is a ZERO behavior change; flat backends (`kucoin` etc.)
just don't declare the split yet.

Also,
- add `validate.get_eps()` returning a backend's defined
  eps per daemon-kind for spawn-time introspection.
- import `NoBsWs`/`open_autorecon_ws` from
  `piker.data._web_bs` directly in `.kraken.broker` (they
  were only re-exported via `.kraken.feed`) so the trading
  mod doesn't depend on the feed mod for ws primitives.

(this patch was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Gud Boi 2026-06-09 17:21:26 -04:00
parent fa8d413c84
commit 66957ffdb0
6 changed files with 75 additions and 12 deletions

View File

@ -52,9 +52,25 @@ __all__ = [
]
# `brokerd` modules
__enable_modules__: list[str] = [
# per-daemon-kind (sub)mod groups: declares which of our
# submods host the eps run by each daemon-actor kind as
# defined by `piker.data.validate._eps`.
# NOTE: `get_mkt_info` and `open_symbol_search` both live
# in `.feed` for this backend (no `symbols.py`).
_brokerd_mods: list[str] = [
'api',
'feed',
'broker',
]
_datad_mods: list[str] = [
'api',
'feed',
]
# tractor RPC enable arg
__enable_modules__: list[str] = list(dict.fromkeys(
_brokerd_mods
+
_datad_mods
))

View File

@ -47,13 +47,25 @@ __all__ = [
]
# tractor RPC enable arg
__enable_modules__: list[str] = [
# per-daemon-kind (sub)mod groups: declares which of our
# submods host the eps run by each daemon-actor kind as
# defined by `piker.data.validate._eps`.
# NOTE: datad-only backend (no `broker.py` yet)!
_brokerd_mods: list[str] = []
_datad_mods: list[str] = [
'api',
'feed',
# 'broker',
]
# tractor RPC enable arg
__enable_modules__: list[str] = list(dict.fromkeys(
_brokerd_mods
+
_datad_mods
))
# passed to ``tractor.ActorNursery.start_actor()``
_spawn_kwargs = {
'infect_asyncio': True,

View File

@ -65,17 +65,18 @@ _brokerd_mods: list[str] = [
]
_datad_mods: list[str] = [
'api',
'feed',
'symbols',
]
# tractor RPC enable arg
__enable_modules__: list[str] = (
__enable_modules__: list[str] = list(dict.fromkeys(
_brokerd_mods
+
_datad_mods
)
))
# passed to ``tractor.ActorNursery.start_actor()``
_spawn_kwargs = {

View File

@ -66,10 +66,24 @@ __all__ = [
]
# tractor RPC enable arg
__enable_modules__: list[str] = [
# per-daemon-kind (sub)mod groups: declares which of our
# submods host the eps run by each daemon-actor kind as
# defined by `piker.data.validate._eps`.
_brokerd_mods: list[str] = [
'api',
'broker',
]
_datad_mods: list[str] = [
'api',
'feed',
'symbols',
]
# tractor RPC enable arg
__enable_modules__: list[str] = list(dict.fromkeys(
_brokerd_mods
+
_datad_mods
))

View File

@ -73,10 +73,12 @@ from piker.log import (
get_logger,
)
from piker.data import open_symcache
from . import api
from .feed import (
from piker.data._web_bs import (
open_autorecon_ws,
NoBsWs,
)
from . import api
from .feed import (
stream_messages,
)
from .ledger import (

View File

@ -91,6 +91,24 @@ _eps: dict[str, list[str]] = {
}
def get_eps(
mod: ModuleType,
kind: str, # 'middleware' | 'datad' | 'brokerd'
) -> dict[str, Callable]:
'''
Return the daemon-kind's ep funcs defined by the backend
`mod`, keyed by ep name; any eps from `_eps[kind]` not
implemented by the backend are excluded.
'''
return {
name: ep
for name in _eps[kind]
if (ep := getattr(mod, name, None))
}
def validate_backend(
mod: ModuleType,
syms: list[str],