mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-06-11 01:14:45 +02:00
feat(dispatcher): per-fire cooldown independence via _cooldown_suffix
Each WFIGS fire event now carries its irwin_id as _cooldown_suffix in event.data. The dispatcher incorporates this suffix into the cooldown key region field, giving each fire its own independent cooldown slot instead of sharing one per (toggle, category, region). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f320333f5f
commit
34e2e3f040
2 changed files with 6 additions and 1 deletions
|
|
@ -274,6 +274,7 @@ def _attach_commit_handles(data: Optional[dict], *, irwin_id: str,
|
||||||
|
|
||||||
data["_on_broadcast_committed"] = _on_commit
|
data["_on_broadcast_committed"] = _on_commit
|
||||||
data["_broadcast_audit"] = {"table": "fires", "pk": irwin_id}
|
data["_broadcast_audit"] = {"table": "fires", "pk": irwin_id}
|
||||||
|
data["_cooldown_suffix"] = irwin_id
|
||||||
|
|
||||||
|
|
||||||
# ---------- helpers -------------------------------------------------------
|
# ---------- helpers -------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -360,10 +360,14 @@ class Dispatcher:
|
||||||
# ---------- Section 2 — per-toggle cooldown ----------
|
# ---------- Section 2 — per-toggle cooldown ----------
|
||||||
cooldown_s = int(getattr(tog, "cooldown_seconds", 300) or 0)
|
cooldown_s = int(getattr(tog, "cooldown_seconds", 300) or 0)
|
||||||
if cooldown_s > 0:
|
if cooldown_s > 0:
|
||||||
|
suffix = (event.data or {}).get("_cooldown_suffix", "")
|
||||||
|
region_key = event.region or "*"
|
||||||
|
if suffix:
|
||||||
|
region_key = f"{region_key}|{suffix}"
|
||||||
ck = (
|
ck = (
|
||||||
getattr(tog, "name", "") or fam,
|
getattr(tog, "name", "") or fam,
|
||||||
event.category,
|
event.category,
|
||||||
event.region or "*",
|
region_key,
|
||||||
)
|
)
|
||||||
now = time.time()
|
now = time.time()
|
||||||
last_fired = self._toggle_cooldown.get(ck)
|
last_fired = self._toggle_cooldown.get(ck)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue