Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created February 4, 2026 13:43
Show Gist options
  • Select an option

  • Save dcomartin/3ae35ad5ededae8337c4e71a0d9bd2f7 to your computer and use it in GitHub Desktop.

Select an option

Save dcomartin/3ae35ad5ededae8337c4e71a0d9bd2f7 to your computer and use it in GitHub Desktop.
// Acquire lock for OrderId (implementation varies)
var distributedLock = new DistributedLock();
using var lease = await distributedLock.Acquire(cmd.OrderId);
if (!lease.Acquired) return; // or wait
var receipt = await paymentGateway.Charge(cmd.OrderId, cmd.Amount);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment