Examples

Page 7 of 14

rustSnippet

Tokio Timeout With select!

Race an async operation against a timer using tokio select!, so a slow future is abandoned cleanly when the deadline fires first.

sqlSnippet

Select For Update Skip Locked

Claim a batch of jobs from a queue by locking only unlocked rows, letting concurrent workers drain the queue without blocking each other.

sqlSnippet

Upsert With ON CONFLICT

Insert a row or update it when the unique key already exists, in one atomic statement that avoids a race between read and write.

typescriptSnippet

Typed Async Retry Helper

A generic retry helper that preserves the resolved value type, caps attempts, and backs off between failures without losing type information.

typescriptSnippet

Express Rate Limit Redis Store

Apply distributed rate limiting in Express with express-rate-limit backed by a Redis store, keying by user identity and API token.

typescriptSnippet

Generic API Response Envelope

Wrap API payloads in a generic envelope type carrying status, data, and optional error metadata so clients get full inference from a single shape.

typescriptSnippet

Next SSR Error Boundary Recovery

Contain server rendering failures in Next.js with route-level error boundaries, distinguishing retryable render errors from hard failures.

typescriptSnippet

Pino Multi-Transport Log Routing

Route Pino logs to multiple transports in parallel, sending errors to a dedicated sink while pretty console output stays development-only.