api-platform-resilience
Skill2 starsChanged 6 months agoMITView on GitHub
Build resilience patterns around an API Platform 4.3 app — Circuit Breaker (Closed → Open → Half-Open) on external dependencies (ERP, payment, search), cached fallback on Open state with a `_notice.type: degraded_mode` marker in the response, asynchronous writes for slow upstreams (HTTP 202 + status: pending_erp_processing dispatched via Messenger with exponential-backoff retry + DLQ + Symfony Workflow lifecycle), and exposure of the current status through the API. Trigger when the API depends on a third-party service (ERP, CRM, payment gateway, mailer, search engine), on "circuit breaker", "degraded mode", "async write", "retry policy", "DLQ", or "what if the ERP is down".
In this repository52 other files it gives its agents.
- api-platform-dto-resourcesSkill
- api-platform-errorsSkill
- api-platform-file-uploadSkill
- api-platform-filtersSkill
- api-platform-identifiersSkill
- api-platform-mcpSkill
- api-platform-mutatorsSkill
- api-platform-openapiSkill
- api-platform-paginationSkill
- api-platform-performanceSkill
- api-platform-resourcesSkill
- api-platform-securitySkill
- api-platform-serializationSkill
- api-platform-state-processorsSkill
- api-platform-state-providersSkill
- api-platform-testsSkill
- api-platform-upgradeSkill
- api-platform-userSkill
- api-platform-versioningSkill
- bootstrap-checkSkill
- brainstormingSkill
- config-env-parametersSkill
- controller-cleanupSkill
- cqrs-and-handlersSkill
- daily-workflowSkill
- doctrine-batch-processingSkill
- doctrine-fetch-modesSkill
- doctrine-fixtures-foundrySkill
- doctrine-migrationsSkill
- doctrine-relationsSkill
- doctrine-transactionsSkill
- effective-contextSkill
- executing-plansSkill
- functional-testsSkill
- interfaces-and-autowiringSkill
- makefile-disciplineSkill
- messenger-retry-failuresSkill
- ports-and-adaptersSkill
- quality-checksSkill
- rate-limitingSkill
- runner-selectionSkill
- strategy-patternSkill
- symfony-cacheSkill
- symfony-messengerSkill
- symfony-schedulerSkill
- symfony-votersSkill
- tdd-with-pestSkill
- tdd-with-phpunitSkill
- test-doubles-mockingSkill
- using-symfony-superpowersSkill
- value-objects-and-dtosSkill
- writing-plansSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
No silent fallback: Always surface degraded mode in the response so the client can decide.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
API Platform 4.3 — Resilience
Use when
- The API depends on a third-party service (ERP, CRM, payment, mailer, search).
- Writes are slow and should not block the user request.
- The third-party is intermittently unreliable.
- A degraded-mode response is preferable to a 5xx.
Default workflow
- Identify each external dependency. Decide its criticality (must succeed sync vs degraded fallback acceptable).
- Wrap external calls in a Circuit Breaker with three states (Closed / Open / Half-Open).
- On Open: serve a cached fallback and add
_notice.type: degraded_modeto the response. - For slow writes: persist a
pending_*status, dispatch a Messenger command, return HTTP 202. - Model the lifecycle with Symfony Workflow (
draft → pending_erp_processing → processed | failed). - Configure exponential backoff retry + DLQ on the Messenger transport.
Guardrails
- No silent fallback. Always surface degraded mode in the response so the client can decide.
- Idempotency on external calls — assume retries will happen.
- Timeouts on every HTTP / RPC call — never block indefinitely.
- DLQ monitored. Failures accumulating in
failedmust trigger an alert; don'tmessenger:failed:retryblindly.
Progressive disclosure
SKILL.mdcovers posture and rules.reference.mdcarries the full patterns: Circuit Breaker implementation (states, transitions, fallback cache), degraded-mode JSON shape, async write end-to-end (Processor, status, Messenger transport, retry strategy, failed transport, Workflow), exposing the status through the API.
Output contract
- Each external dependency wrapped in a Circuit Breaker (and tested).
- Async writes return HTTP 202 with a queryable
statusfield. - Messenger retry strategy + DLQ configured per transport.
- Workflow definition (
draft → pending → processed | failed) explicit. - Tests cover the Open state (degraded fallback), the failure transport, and the recovery path.
References
reference.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

