version, and every change says which version it was based on.
The rule
- Read the record. Its
versionis in the response. - Send that value unchanged as
expectedVersionin the change. - If someone changed the record in between, Brelio answers
409and changes nothing. Read it again, decide again, retry.
409 VERSION_CONFLICT
Treat the version as opaque
Copyversion exactly as you read it. Do not build, parse, compare or increment it. Its form depends on the resource and may change:
Send it with the type the resource gave it: a string where
version is a string, a number where it is a number.
Operations that need it
Creates do not take one: there is nothing to overwrite.
Handle a 409
Do not retry the same request: it will fail again. Read the record, check whether your change still makes sense with the new data (the appointment may already be cancelled), and send a new request with the new version and a newIdempotency-Key.
Node.js