Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Make the health endpoint reflect the readiness of critical dependencies
A readiness endpoint must fail while a subscription, consumer, or connection the service exists to run is not established - otherwise the orchestrator routes traffic to a pod that silently does nothing.
Bad example
| 1 | let subscribed = false; |
| 2 |
|
| 3 | async function start() { |
| 4 | await client.init(); // retries forever, never throws |
| 5 | await client.subscribe(TOPIC, onMessage); |
| 6 | subscribed = true; |
| 7 | } |
| 8 | void start(); |
| 9 |
|
| 10 | // Always OK, even when the subscription never happened |
| 11 | app.get("/_health", (_req, res) => res.status(200).send("OK")); |
Explanation (EN)
The endpoint reports only that the HTTP listener is up. If the dependency never connects, the probe still passes and the orchestrator sends traffic to an instance that processes nothing.
Objašnjenje (HR)
Endpoint javlja samo da HTTP slusatelj radi. Ako se ovisnost nikad ne spoji, proba i dalje prolazi i orkestrator salje promet na instancu koja ne obraduje nista.
Good example
| 1 | let subscribed = false; |
| 2 |
|
| 3 | async function start() { |
| 4 | await client.init(); |
| 5 | await client.subscribe(TOPIC, onMessage); |
| 6 | subscribed = true; |
| 7 | } |
| 8 | void start(); |
| 9 |
|
| 10 | app.get("/_health", (_req, res) => |
| 11 | subscribed ? res.status(200).send("OK") : res.status(503).send("subscription not established"), |
| 12 | ); |
Explanation (EN)
The probe fails while the service cannot do its job, so the deploy stalls visibly instead of succeeding into a silent outage.
Objašnjenje (HR)
Proba pada dok servis ne moze raditi svoj posao, pa se deploy vidljivo zaustavi umjesto da uspije u tihi ispad.
Notes (EN)
Separate liveness (is the process alive) from readiness (can it serve). Retry-forever client libraries make this rule essential: they remove the crash that used to signal the failure.
Bilješke (HR)
Odvoji liveness (je li proces ziv) od readiness (moze li posluzivati). Biblioteke koje beskonacno ponavljaju spajanje cine ovo pravilo nuznim jer uklanjaju pad koji je prije signalizirao kvar.