{"recipes":[{"id":"resume-csv","title":"Resume a CSV import without duplicates","tags":["csv","import","retry","database","idempotent"],"summary":"Use a stable source ID and commit the row and its checkpoint together.","steps":["Add a UNIQUE constraint on the source row ID.","Upsert each row using that ID and store the checkpoint within the same database transaction.","Advance the checkpoint only after commit. Replay the last batch after interruption."],"example":"INSERT INTO contacts (source_id, email) VALUES (?, ?) ON DUPLICATE KEY UPDATE email = VALUES(email);","source":"https://mariadb.com/kb/en/insert-on-duplicate-key-update/"},{"id":"webhook-retries","title":"Process webhook deliveries once","tags":["webhook","duplicate","retry","event","idempotent"],"summary":"Record the provider's event ID before performing work.","steps":["Verify the provider's signature against the raw request body.","Store the provider name and event ID under a unique constraint, and enqueue the work durably in the same transaction.","Acknowledge after commit. Use an idempotency key for any external side effect."],"example":"UNIQUE (provider, event_id)","source":"https://docs.stripe.com/webhooks#handle-duplicate-events"},{"id":"respect-rate-limits","title":"Retry a rate-limited request","tags":["429","rate limit","retry","http","api"],"summary":"Honor Retry-After and cap the number of attempts.","steps":["Read the Retry-After header when a server returns HTTP 429. Accept either seconds or an HTTP date.","If the header is absent, use exponential backoff with jitter and cap the delay.","Only retry side effects when the operation is idempotent. Return an explicit failure after the retry budget expires."],"example":"Retry-After: 30","source":"https://www.rfc-editor.org/rfc/rfc9110.html#name-retry-after"},{"id":"paginate-api","title":"Resume a paginated API sync","tags":["pagination","cursor","page","sync","api"],"summary":"Persist the cursor after committing the records it belongs to.","steps":["Follow the next-page URL or cursor provided by the API.","Upsert the returned items and save the next cursor in the same transaction.","On resume, use the last saved cursor. Stop when the response has no next page."],"example":"Link: <https://api.example.com/items?page=2>; rel=\"next\"","source":"https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api"}]}