34 lines
974 B
Python
34 lines
974 B
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class ChannelConfig:
|
|
name: str
|
|
outbox_path: Path
|
|
upstream_url: str | None # None => /api/<channel>/* returns 501
|
|
upstream_path: str = "/api/" # path prefix when proxying (channel injected via {channel})
|
|
|
|
|
|
def build_channels(
|
|
storage_root: Path,
|
|
sre_upstream: str,
|
|
tss_upstream: str | None,
|
|
) -> dict[str, ChannelConfig]:
|
|
return {
|
|
"sre": ChannelConfig(
|
|
name="sre",
|
|
outbox_path=storage_root / "external_bridge_outbox.jsonl",
|
|
upstream_url=sre_upstream.rstrip("/"),
|
|
upstream_path="/api/",
|
|
),
|
|
"tss": ChannelConfig(
|
|
name="tss",
|
|
outbox_path=storage_root / "tss_bridge_outbox.jsonl",
|
|
upstream_url=(tss_upstream.rstrip("/") if tss_upstream else None),
|
|
upstream_path="/api/tss/",
|
|
),
|
|
}
|