Initial commit

This commit is contained in:
ThePetrovich 2026-08-17 22:50:10 +08:00
commit 5cda7bc309
28 changed files with 1173 additions and 0 deletions

29
yksa_kit/conf.py Normal file
View file

@ -0,0 +1,29 @@
"""The two settings every service must declare, and their fallbacks."""
from __future__ import annotations
from django.conf import settings
DEFAULT_SERVICE = "yksa"
def service() -> str:
"""Short service slug: ``tdas``, ``odms``, ``ops``.
Namespaces every cache key this package writes. The services share one Redis,
so a wrong or missing value silently merges two rate-limit budgets.
"""
return getattr(settings, "YKSA_SERVICE", DEFAULT_SERVICE)
def user_agent() -> str:
"""Identifies us to the upstreams we poll; several ban unattributed clients."""
return getattr(
settings,
"YKSA_USER_AGENT",
f"yksa-{service()}/0.1 (+https://{service()}.tmtc.yksa.space)",
)
def cache_key(*parts: str) -> str:
return ":".join((service(), *parts))