Code Explainers
Code explainers tagged #async
rust
use axum::{extract::{Path, State}, http::StatusCode, Json}; use serde::Serialize; use std::sync::Arc;
Concurrent dashboard aggregation in Axum
concurrency
error-handling
graceful-degradation
Intermediate
7 steps
rust
use std::sync::Arc; use axum::{ extract::State,
Offloading work with a channel in Axum
background-jobs
message-passing
shared-state
Intermediate
9 steps
rust
use std::time::Duration; use axum::{extract::State, http::StatusCode, response::IntoResponse, Json}; use serde::Serialize;
A timeout-guarded health check in Axum
health-check
timeout
error-handling
Intermediate
6 steps
typescript
type Event = Record<string, unknown>; interface BatcherOptions { endpoint: string;
Batching analytics events in TypeScript
batching
buffering
async
Intermediate
8 steps
rust
use std::time::Duration; use tokio::time::sleep; #[derive(Debug)]
Async retry with exponential backoff in Rust
retry
exponential-backoff
async
Intermediate
8 steps
javascript
const cache = new Map(); const inflight = new Map(); async function fetchResults(query) {
Building a typeahead with an LRU cache
caching
lru-eviction
request-deduplication
Intermediate
9 steps
javascript
export function createSearchClient(baseUrl) { let inFlight = null; async function search(query, { signal } = {}) {
Cancelling stale requests in a search client
closures
abortcontroller
async
Intermediate
8 steps
java
@Service public class ReportGenerationService { private final ReportRepository reportRepository;
Async report generation with Spring @Async
async
dependency-injection
completablefuture
Intermediate
7 steps
java
@Service public class OrderService { private final OrderRepository orderRepository;
Decoupling side effects with Spring events
event-driven
transactions
decoupling
Intermediate
8 steps
python
import stripe from fastapi import APIRouter, Request, Header, HTTPException from app.config import settings
Handling Stripe webhooks in FastAPI
webhooks
signature-verification
event-routing
Intermediate
7 steps
rust
use axum::{ response::sse::{Event, KeepAlive, Sse}, routing::get, Router,
Streaming live price ticks with SSE in Axum
server-sent-events
broadcast-channel
streaming
Advanced
8 steps
typescript
type SearchResult = { id: string; title: string; };
Cancelling stale searches with AbortController
abortcontroller
cancellation
async
Intermediate
7 steps
rust
use std::time::Duration; use axum::{routing::get, Router}; use tokio::net::TcpListener;
Graceful shutdown in an Axum server
graceful-shutdown
signal-handling
async
Intermediate
8 steps
rust
use axum::{ extract::State, http::StatusCode, response::IntoResponse,
An async job queue handler in Axum
background-jobs
async
http-202
Intermediate
9 steps
typescript
import { useState, useEffect, useRef, useCallback } from "react"; interface SearchResult { id: string;
A debounced search hook in React
debounce
custom-hooks
abortcontroller
Intermediate
7 steps
typescript
interface RetryOptions { retries?: number; baseDelayMs?: number; maxDelayMs?: number;
Retrying async tasks with exponential backoff
retry
exponential-backoff
async
Intermediate
8 steps
javascript
const PENDING = 'pending'; const FULFILLED = 'fulfilled'; const REJECTED = 'rejected';
Building a Promise from scratch
promises
state-machine
microtasks
Advanced
10 steps