Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
66 lines
2.0 KiB
Python
66 lines
2.0 KiB
Python
"""Env settings for Menivor -> Rally lifecycle events (dogfooding Rally journeys).
|
|
|
|
OFF unless ``RALLY_EVENTS_KEY`` is set. Reading settings never opens a socket.
|
|
|
|
RALLY_EVENTS_KEY workspace event key (``rly_evt_...``), created on
|
|
Rally's Journeys page. Server-side only.
|
|
RALLY_EVENTS_URL Rally base URL (default ``https://vcpeer.com``);
|
|
events go to ``${RALLY_EVENTS_URL}/api/autogtm/events``
|
|
RALLY_EVENTS_TIMEOUT_SECONDS per-request timeout (default 3)
|
|
RALLY_EVENTS_SOURCE ``source`` tag on every event (default ``menivor``)
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from dataclasses import dataclass
|
|
from typing import Mapping, Optional
|
|
|
|
Env = Mapping[str, Optional[str]]
|
|
|
|
DEFAULT_URL = "https://vcpeer.com"
|
|
DEFAULT_TIMEOUT_S = 3.0
|
|
DEFAULT_SOURCE = "menivor"
|
|
EVENTS_PATH = "/api/autogtm/events"
|
|
KEY_PREFIX = "rly_evt_"
|
|
|
|
|
|
def _read(env: Env, key: str) -> Optional[str]:
|
|
raw = env.get(key)
|
|
value = raw.strip() if isinstance(raw, str) else ""
|
|
return value or None
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class RallySettings:
|
|
key: Optional[str]
|
|
base_url: str
|
|
timeout_s: float
|
|
source: str
|
|
|
|
@property
|
|
def enabled(self) -> bool:
|
|
return bool(self.key and self.key.startswith(KEY_PREFIX))
|
|
|
|
@property
|
|
def events_url(self) -> str:
|
|
return f"{self.base_url}{EVENTS_PATH}"
|
|
|
|
|
|
def load_settings(env: Optional[Env] = None) -> RallySettings:
|
|
env = env if env is not None else os.environ
|
|
timeout_raw = _read(env, "RALLY_EVENTS_TIMEOUT_SECONDS")
|
|
try:
|
|
timeout = float(timeout_raw) if timeout_raw else DEFAULT_TIMEOUT_S
|
|
except ValueError:
|
|
timeout = DEFAULT_TIMEOUT_S
|
|
if timeout <= 0:
|
|
timeout = DEFAULT_TIMEOUT_S
|
|
base = _read(env, "RALLY_EVENTS_URL") or DEFAULT_URL
|
|
return RallySettings(
|
|
key=_read(env, "RALLY_EVENTS_KEY"),
|
|
base_url=base.rstrip("/"),
|
|
timeout_s=timeout,
|
|
source=_read(env, "RALLY_EVENTS_SOURCE") or DEFAULT_SOURCE,
|
|
)
|