Documentation sections
Why a cascade#
A vendor goes down, errs or gets blocked. If a fallback exists but a person switches to it during an incident, there is effectively none. The cascade switches by itself, with one condition: it must not repeat an action that already happened. A message sent twice is unpleasant; a payout made twice costs money.
Three rules#
| Rule | For what | What it does |
|---|---|---|
safe | Operations without an outside effect or idempotent ones: list screening, AI text, opening a KYC case, the outbound proxy. | Any failure moves the request to the next provider. |
on_reject | Operations with an outside effect: an email, an SMS, a push, a deposit and a payout. | To the next provider only after an explicit refusal before the effect. An unknown outcome and any other error stop the cascade. |
none | Games and VPN: a game belongs to its supplier, a VPN profile lives on the server that issued it. | No cascade: only the first usable one is tried and its error is returned as it is. |
The outcome of an attempt and the decision#
For operations with an outside effect a connector must tell the outcomes apart itself: whether the next one may be tried depends on it. A payout example: the request went to provider A, the answer was lost, and it is unknown whether A paid. Paying through B could pay the player a second time, so the cascade stops and a person or a reconciliation decides. Had A answered refusal, or could not be reached, nothing happened and the payout goes to B.
| What happened at the provider | What it is called in the code | The cascade for on_reject |
|---|---|---|
| Could not even connect, bad keys, a local validation | CheckFailed | moves on |
| The vendor explicitly refused before acting: a recipient refused, a 4xx on a send, a payment declined | Rejected | moves on; it is not counted as a health failure of the vendor |
| The request may have arrived and the answer was lost: a read timeout, a drop after sending, a 5xx | OutcomeUnknown | stops |
| Any other error (a bug) | an exception | stops |
Routes#
A route is bound to a purpose inside a category (email.system and email.marketing are routed independently). A route has: a project (or all projects), a connector, a priority (lower goes first), whether it is enabled, a weight (the traffic share inside one priority), conditions on country, currency, language and amount range, a note.
- Which list is used. When a project has its own routes for a purpose, only those apply; otherwise the global list; when there are no routes at all the platform behaves as it did before routing (every usable connector in code order). A saved list whose routes are all disabled means no provider (503), not the old behaviour.
- The order. Usable candidates are grouped by priority; inside a priority the order is a weighted random draw without replacement, so the first gets its share of traffic and the rest are fallbacks before the next priority.
- A candidate is usable when the connector exists, is not planned, implements the needed contract, the route is enabled, the connector is built in or connected (not in error, not disabled, not unconfigured), the route's conditions match the request and its circuit breaker is not open. An unknown value (a player without a country) never matches a condition on that value.
The list is exhausted: a 503 no_provider_available answer with the list of attempts and the reasons candidates were skipped.
The circuit breaker#
Each connector has its own circuit breaker. After five failures in a row that happen within five minutes it opens: the connector is skipped for two minutes. Then one probe call is allowed: success closes the breaker, failure opens it again. An explicit refusal by a vendor is not a failure: the vendor answered. The thresholds are the settings routing_fail_threshold, routing_fail_window_seconds, routing_open_seconds.
A state change is written to the exchange log and the event bus (route.open, route.half_open, route.closed). Platform processes learn of it from the log within 5 seconds, and with Valkey at once: the failure counter is shared. Without Valkey everything works the same, only per process.
Capabilities and where they are wired#
The cascade does not work equally everywhere: for some capabilities it is wired into the platform, for others there are only rules and a dry run.
| Capability | Cascade rule | Where it is wired |
|---|---|---|
kyc.identityIdentity verification | safe | wired |
aml.screeningAML and sanctions screening | safe | a helper exists, nothing calls it |
email.systemSystem email | on_reject | wired |
email.marketingMarketing email | on_reject | wired |
sms.systemSystem SMS | on_reject | wired |
sms.marketingMarketing SMS | on_reject | wired |
sms.otpOne-time codes by SMS | on_reject | rules and a dry run only |
push.playerPush and messengers to players | on_reject | wired |
ai.textAI text generation | safe | a helper exists, nothing calls it |
payments.depositDeposits | on_reject | rules and a dry run only |
payments.payoutPayouts | on_reject | rules and a dry run only |
proxy.outboundOutbound proxy | safe | rules and a dry run only |
vpn.staffVPN for staff | none | rules and a dry run only |
games.launchGame launch | none | rules and a dry run only |
Where it is set up#
There is no routes screen in the interface yet. Routes are set by a staff member with the integrations:edit right through the core API /api/admin/integrations/routing (it is not reachable with an external API key). Viewing takes the integrations:view right. Saving a list requires a comment and is written to the action log with the state before and after. The dry run POST /api/admin/integrations/routing/simulate calls nothing: it shows whom the platform would try and in what order for a given country, currency, language and amount. A breaker can be closed by hand.