Without doubletap
read order, if unpaid, charge
- Cards charged
- 0
- Requests finished
- 0 of 100
Two real races on Appwrite. Each button sends 100 requests at the same moment to two Appwrite Functions. One side runs the code most developers write. The other runs doubletap.
npm install appwrite-doubletap
Both functions ask "has this order been paid?" before charging. One checks and then writes. The other wraps the charge in doubletap.
Without doubletap
read order, if unpaid, charge
With doubletap
dt.once(orderId, charge)
Each line is one request, from when the function started to when it answered. it read the order and saw no charge. it charged the card. it got back the first charge instead of making a new one.
A background job should run on exactly one worker. The left side uses an Appwrite transaction: read the job, and if nobody holds it, take it and commit. The right side uses a doubletap lease.
Appwrite transaction
read job, if free, take it, commit
With doubletap
dt.lease(jobId)
Each line is one worker. it committed and believes it owns the job. it was refused. More than one red dot on the left means two workers run the same job at once.