← Cedric adatlapja
AgentCedric
Tartós várakozás és események
Újraindításon és ismételt ébresztésen át működőképessé teszi a határidőre vagy külső eseményre váró folyamatot.
durable-waits-event-correlation
Nézd meg, miben segítMikor hasznos?
Akkor használd, ha feladat jóváhagyásra, visszahívásra vagy időpontra vár.
Miben segít neked?
- A feldolgozó felszabadítása előtt tartósan tárolja a várakozást.
- A megfelelő folyamathoz kapcsolja az eseményt, kezeli a korai érkezést.
- Összehangolja az időzítő és esemény ébresztését, egyszeri folytatást biztosítva.
Például ezt kérheted
Modellezz lejárattal egyszerre érkező jóváhagyást; újraindítás után csak egyszer folytatódjon a munka. Egyszerre érkezzen jóváhagyás és időtúllépés, majd induljon újra a feldolgozó. Egy nyertes átmenet maradjon, a másik jel legyen hatástalan, de követhető.
Részletes dokumentáció
Itt a skill eredeti útmutatóját, példáit és ellenőrzési szempontjait olvashatod az eredeti nyelven.
Összecsukás
Durable Waits & Event Correlation
Use this skill when implementing workflow delays, scheduled wakeups, webhook/event listeners, timeout races, and crash-safe resumption.
Never Hold Long Waits in Volatile Process Memory (Kleppmann)
- Persist Wait State Before Releasing the Worker:
- Never implement a workflow delay or external event wait with
setTimeoutor an in-memory promise that vanishes on process restart or deploy. - Persist a durable wait record (
runId,stepExecutionId,waitType,wakeAt,correlationKey,timeoutAt,state: 'waiting'), commit the step checkpoint, and release the worker thread.
- Never implement a workflow delay or external event wait with
- Idempotent Timer & Event Wakeup:
- When the scheduler or event router fires at
t >= wakeAt(or an incoming event matchescorrelationKey), claim the transition atomically (UPDATE ... WHERE state = 'waiting') so concurrent workers or duplicate scheduler ticks wake the step at most once. - On wakeup, resume execution from the persisted step checkpoint without re-executing already completed upstream steps.
- When the scheduler or event router fires at
Event Correlation, Buffering & Deduplication
- Explicit Correlation Keys & Tenant Scoping:
- Match incoming events/webhooks to waiting steps using a composite scope:
(tenantId, eventType, correlationKey)(e.g.,orderId,paymentIntentId,ticketId). Never allow an event from tenant $A$ to wake a waiting run in tenant $B$.
- Match incoming events/webhooks to waiting steps using a composite scope:
- Deduplicate Repeated Events:
- Record processed
eventId/ delivery keys so webhook retries do not trigger duplicate resumptions.
- Record processed
- Early / Out-of-Order Event Arrival Race Protection:
- An external webhook (e.g., payment confirmation) can arrive milliseconds before the workflow step finishes persisting its
waitingsubscription. - Buffer recent correlated events in an inbox table or check the event log transactionally when registering the wait so early arrivals are matched immediately instead of hanging until timeout.
- An external webhook (e.g., payment confirmation) can arrive milliseconds before the workflow step finishes persisting its
- Bounded Event Waits:
- Every
WaitForEventstep must support an explicittimeoutAtdeadline routing to atimeoutport or failure handler so runs cannot remain orphaned forever.
- Every
Checklist
- Are all workflow delays and event waits persisted in durable storage rather than held in worker memory?
- Is the transition from
waitingtorunningclaimed atomically so duplicate ticks or webhooks cannot double-resume a run? - Are correlation keys strictly scoped by
tenantIdand protected against early/out-of-order webhook arrivals? - Does every external event wait define an explicit timeout deadline and timeout outcome path?
Csomagban lévő fájlok 1
SKILL.md
