The Mediator (jq)
Centralize chaotic node communication through a single, omniscient hub.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Mediator
ARCANUM SCHOOL: Enchantment // Compulsion
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
# Nodes do not talk to each other; they emit states
# [ { "id": "A", "status": "critical" }, { "id": "B", "status": "idle" } ]
# The Mediator coordinates the global response
def mediator_hub:
(map(select(.status == "critical")) | length) as $critical_count
| if $critical_count > 0 then
map(if .status == "idle" then .status = "assisting" else . end)
else
.
end;
# Execution
.system_nodes | mediator_hub
In a sprawling micro-ecosystem, nodes attempting to influence each other lead to entangled, spaghetti-like code. The Mediator absorbs the state of the entire network, evaluates the global context, and dictates the resulting shifts in behavior. The nodes remain blind to one another, answering only to the hub.
Runic Tags:
#jq
#json
#transmutation
#gof