Conversation
Benchmark ResultsComparison of Open to see the benchmark results
Generated by phpbench against commit 2caea11 |
|
Pretty slick, man! |
|
Should be fine for review, can't seem to add/change much. |
brendt
left a comment
There was a problem hiding this comment.
Don't forget about adding the docs :) My suggestion would be to have a section both in the routing and command bus docs
Also: would there be any impact if we worked on FrankenPHP worker mode? Somethings we already need to account for?
packages/idempotency/src/Exceptions/UnsupportedIdempotencyPlatform.php
Outdated
Show resolved
Hide resolved
Definitely, just wanted to gather some feedback first and iterate with things, to make sure there is no stale documentation anywhere when things get into their final form.
Yes, we'd potentially have to revisit |
Overview
This PR adds idempotency support for HTTP routes and command bus commands. It prevents duplicate side effects by storing the result of the first execution and replaying it for subsequent requests with the same idempotency key.
Payment processing, order creation, resource provisioning and any operation where retrying the same request should not produce duplicate side effects. Timeouts, retries by clients, and accidental double clicks all cause the same problem: the server can't distinguish a retry from a new request.
Routes
Add
#[Idempotent]to a controller method. Clients send anIdempotency-Keyheader. The first request executes normally and caches the response. Subsequent requests with the same key replay the cached response.Example:
Commands
Mark a command with
#[IdempotentCommand]. Duplicate dispatches with the same payload are silently skipped.Example:
Commands can also provide explicit keys via
HasIdempotencyKey.Example:
Known limitations at the opening of PR
No differentiation between in-progress/same key, different payload casesScoping is weak, we need an additional component (user-provided resolver)Heartbeat renewal is not implemented yetWe need to target onlyPOSTandPATCHmethods, disallow othersWonftixes (design decision)
posixandpcntlusage