SQLite Job Queue with Leases
Build a durable SQLite job queue that claims work with a time-limited lease, retries abandoned jobs, and deletes finished rows.
Page 47 of 50
Build a durable SQLite job queue that claims work with a time-limited lease, retries abandoned jobs, and deletes finished rows.
Parse text/event-stream frames into structured events and wrap the HTTP read loop with bounded reconnect attempts and backoff.
Emit JSON log lines with a custom formatter, attach request context through ContextVar, redact secret fields, and keep UTC timestamps.
Rank the most distinctive keywords in a small document set with term frequency, inverse document frequency, and stop-word filtering.
Implement a monotonic-clock token bucket that allows bursts, refills at a fixed rate, and returns the wait time when a request is denied.
Parse TOML into frozen dataclasses, validate nested service and database tables, and report missing or mistyped keys with clear errors.
Order build targets from a prerequisite graph with Kahn's algorithm and fail loudly when a dependency cycle prevents a complete order.
Insert weighted words into a trie, autocomplete by prefix, rank suggestions by weight, and reject empty or non-string input.
Turn Unicode headings into stable ASCII URL slugs with transliteration, separator collapsing, and length limits.
Track connected components with union by rank and path compression, then answer connectivity queries in near-constant time.
Encode non-negative integers as compact LEB128 bytes and decode them sequentially, with ZigZag helpers for signed values.
Track count, mean, and sample standard deviation in one pass with Welford's algorithm, avoiding catastrophic cancellation.
Read a large XML document without loading it whole, yield one record at a time, and clear processed elements to free memory.
Parse repeated query parameters into a multimap, rebuild a stable query string, and read typed single-value flags safely.
Keep the newest N items in a fixed-size circular buffer, return the evicted value on overflow, and read the latest slice.
Turn untrusted filenames into safe basenames by stripping paths, blocking reserved names, normalizing Unicode, and limiting length.
Split plain text into sentences while keeping common abbreviations, decimals, and closing quotes attached to the right sentence.
Run safe parameterized SQLite queries with bound values, allowlisted sort columns, dynamic IN clauses, and repository error handling.
Encode and decode length-prefixed binary packets with a magic header, version checks, payload limits, and truncation errors.
Walk a directory without following links that escape the root, recording skipped entries and enforcing a depth limit.
Map a function over items with a bounded thread pool, preserve input order, and cancel pending work when the overall deadline expires.
Normalize scheme, host, port, dot segments, and query order while dropping tracking parameters, producing a stable cache key.
Reload configuration atomically by swapping an Arc while readers keep lock-free snapshots, with no downtime or partial state.
Share a child cancellation token with each worker and cancel the whole batch when the execution budget runs out.
Compare secrets without early exit so timing does not leak the matching prefix, and keep the result observable with black_box.
Schedule named tasks with run-at timestamps in a binary heap, pop everything that is due, and inspect the next deadline.
Parse and build big-endian length-prefixed frames with a version byte, flags, checksum, and explicit truncation errors.
Match strings against star and question-mark patterns with backtracking that avoids exponential blowup on repeated stars.
Count differing bits between equal-length byte slices, report bit similarity, and reject inputs of unequal length.
Convert bytes to lowercase hex and back, accepting an optional prefix and embedded whitespace while rejecting invalid digits.
Parse INI sections and key-value pairs into a sorted map, trimming quotes and rejecting malformed headers or empty keys.
Identify PNG, JPEG, GIF, PDF, ZIP, and gzip files from their leading bytes, then check whether the extension agrees.
Normalize an untrusted relative path component by component and reject anything that would climb above the allowed root.
Serve typed JSON from Axum 0.8 with path and query extractors, explicit 400 and 404 errors, and shared map state behind an Arc.
Keep the largest K values from a stream in a bounded min-heap using Reverse, then return them sorted from highest to lowest.
Coordinate producers and consumers with a bounded VecDeque, Mutex, and two condition variables for blocking push and pop.
Split identifiers on separators and case boundaries, then rebuild them as snake_case or camelCase without external crates.
Track failures with closed, open, and half-open states so a failing dependency is rejected fast until a cooldown trial succeeds.
Deserialize CSV records into typed Serde structs with header mapping, numeric parsing, and an error on negative quantities.
Model transport, timeout, and validation failures in one error enum, then decide retryability without matching on strings.
Model configuration failures with a custom Rust error enum, Display and Error implementations, From conversion, and preserved parse causes.
Inject a manually advanced clock into token expiry logic so tests never sleep and boundary conditions stay reproducible.
Support point updates and range-sum queries in logarithmic time with a compact binary indexed tree and low-bit navigation.
Receive filesystem notifications through notify, keep the watcher alive with a handle, and collapse rapid events into one batch.
Reuse expensive objects through a mutex-backed pool whose guard returns the item automatically on drop, with a factory fallback.
Signal shutdown with Tokio Notify, let each worker finish its current cycle, and join every task before the process exits.
Compress an in-memory payload with flate2's GzEncoder, decompress it through GzDecoder, and verify the round trip byte for byte.
Track in-flight and completed requests by idempotency key, replay stored responses within a TTL, and release abandoned work.
Chain Rust iterators to filter refunded orders, fold totals, group revenue by customer, and rank the top accounts without extra crates.
Compute rolling sums and averages over fixed-size windows with slice iterators, avoiding index loops and extra allocations.
Implement an LRU cache with a hash map and a recency queue, evicting by capacity and expiring entries by timestamp.
Initialize process-wide configuration exactly once across threads with std::sync::OnceLock, then read it without locks or clones.
Model order status as an enum and allow only the transitions place, pay, ship, and cancel from valid states.
Search text for every occurrence of a pattern with a rolling Rabin-Karp hash and verify collisions by direct comparison.
Retry fallible async operations with capped exponential delays, per-attempt jitter, and a final error carrying the attempt count.
Select healthy backends in round-robin order with an atomic cursor, skipping failed nodes and returning none when all fail.
Encode repeated characters with counts and decode the result back, rejecting zero counts and dangling numeric prefixes.
Map slices in chunks with std::thread::scope, join worker results in order, and avoid unsafe shared mutable state.
Accept a space-separated string or a JSON array for one Serde field using a custom Visitor, defaults, and unknown-field rejection.
Map Rust field names to camelCase and reserved API keys with serde attributes while keeping a strongly typed struct.
Deduplicate concurrent async lookups for the same key so one leader performs the work and followers receive the shared result.
Consume a text/event-stream response with reqwest and parse event, data, and comment lines into complete server-sent events.
Create a unique temporary directory guarded by Drop cleanup, reject escaping write paths, and remove nested files automatically.
Refill a token bucket from a monotonic clock, allow short bursts, and compute how long a caller must wait when it is empty.
Share a tokio semaphore across spawned tasks, hold a permit for each job, and collect every result with JoinSet.
Bound each async call with tokio timeout, retry transient failures with linear backoff, and return one typed exhaustion error.
Recursively merge TOML tables so environment overlays change only the keys they declare while preserving sibling settings.
Derive RFC 6238 time-based one-time codes from a Base32 secret, with counter packing, dynamic truncation, and modulo digits.
Build a trie from weighted words, return prefix matches sorted by score, and cap the output to keep responses small.
Wrap numeric identifiers in a newtype that parses a prefixed string, rejects zero values, and prints a padded canonical form.
Generate 26-character Crockford base32 identifiers from a millisecond timestamp and monotonic randomness that sorts correctly.
Percent-encode URL query keys and values as UTF-8, preserving unreserved characters and encoding spaces as %20.
Walk a directory tree without following symlinks, skip hidden entries, and collect regular files matching one extension.
Parse semantic versions and requirement ranges, test whether a release satisfies a range, and pick the highest matching version.
Split a command line into arguments with single quotes, double quotes, escapes, and explicit errors for unterminated quotes.
Validate archive entry names before extraction, blocking absolute paths, parent traversal, and anything outside the destination.
Spawn a batch of async tasks, collect results as they finish, and abort everything still running when a deadline expires.
Wrap credentials in a type that wipes memory on drop, redacts itself in debug output, and zeroes temporary buffers explicitly.
Add PostgreSQL partial and expression indexes for pending orders, active subscriptions, and case-insensitive email lookups.
Explode a multi-level bill of materials with a PostgreSQL recursive CTE, guard against cycles, and roll leaf costs up the assembly.
Implement a PostgreSQL upsert that restocks existing inventory, inserts new SKUs, and rejects stale writes using a version guard.
Use PostgreSQL window functions with explicit ROWS frames to compute running totals, moving averages, and each day's share of an account.
Find a shortest path through a rectangular ASCII maze with A*, Manhattan distance, wall checks and clear unreachable handling.
Add or subtract months in UTC while clamping the day to the target month's last day, avoiding date rollover bugs.
Encrypt and authenticate strings with AES-256-GCM, deriving the key from a passphrase and random salt via scrypt.
Render terminal tables with column alignment, ignoring ANSI color codes in width calculations and adding a header separator.
Tokenize and evaluate arithmetic expressions with precedence, parentheses, unary signs, powers and modulo.
Group values from async iterables into fixed-size arrays, yielding full batches and a final partial batch without buffering all.
Coalesce async writes into bounded batches, apply backpressure at a high-water mark, serialize flushes and drain on close.
Encode non-negative integers as short Base62 strings and decode them back with BigInt, rejecting invalid input.
Test set membership with a compact Bloom filter using double hashing, a configurable error rate and a false-positive estimate.
Combine runtime parsers with branded TypeScript types so validated emails, user IDs and slugs cannot be mixed up by accident.
Move a UTC date forward or backward by business days while skipping weekends and an optional set of holiday date keys.
Store the most recent items in a fixed-capacity circular buffer with overwrite eviction, indexed access, iteration, and clearing.
Compute WCAG contrast ratios from hex colors and check AA or AAA thresholds for normal text and large text.
Assert type equality at build time with Equal, Expect, IsAny and tiny runtime helpers, catching type regressions during tsc.
Format and parse Content-Range response headers for byte ranges, validating start, end and total values in both directions.
Parse media types and parameters from Content-Type headers, handling quoted strings, charset and duplicate names.
Estimate stream frequencies in fixed memory with a count-min sketch, multiple hash rows and conservative updates.
Compute CRC32 checksums for strings and byte arrays using a precomputed lookup table, with hex output for wire formats.