Code Explainers
Code explainers tagged #backpressure
rust
use std::time::Duration; use tokio::sync::mpsc; use tokio::time::{interval, MissedTickBehavior};
A token-bucket rate limiter in Tokio
rate-limiting
channels
async
Advanced
8 steps
javascript
const express = require('express'); const router = express.Router(); router.get('/exports/orders', async (req, res) => {
Streaming a large JSON export in Express
streaming
backpressure
cursors
Advanced
9 steps
go
func (h *ReportHandler) ExportTransactions(w http.ResponseWriter, r *http.Request) { ctx := r.Context() from, to, err := parseDateRange(r.URL.Query())
Streaming a CSV export in Go
streaming
http
csv
Intermediate
8 steps
rust
use axum::{ body::Body, extract::State, http::{header, StatusCode},
Streaming a DB migration with Axum
streaming
keyset-pagination
backpressure
Advanced
8 steps
javascript
import { NextResponse } from 'next/server'; import { db } from '@/lib/db'; function csvCell(value) {
Streaming a CSV export in a Next.js route
streaming
csv
readablestream
Advanced
9 steps
java
public class RequestThrottler { private final Semaphore permits; private final long acquireTimeoutMillis;
Bounding concurrency with a Semaphore in Java
concurrency
semaphore
rate-limiting
Intermediate
6 steps
rust
use std::sync::Arc; use axum::{ extract::{Multipart, State}, http::StatusCode,
Throttling file uploads in Axum with a Semaphore
concurrency
backpressure
multipart
Advanced
8 steps
rust
use axum::{ body::Body, extract::State, http::{header, StatusCode},
Streaming NDJSON from Postgres in Axum
streaming
backpressure
async
Advanced
9 steps
rust
use axum::{ extract::State, response::sse::{Event, KeepAlive, Sse}, Json,
Proxying an SSE chat stream in Axum
server-sent-events
streaming
async-generators
Advanced
10 steps
javascript
import { NextResponse } from 'next/server'; import { createWriteStream } from 'node:fs'; import { mkdir } from 'node:fs/promises'; import { pipeline } from 'node:stream/promises';
Streaming file uploads in a Next.js route
file-upload
streams
validation
Intermediate
9 steps
java
@RestController @RequestMapping("/api/reports") public class OrderReportController {
Streaming a CSV export in Spring
streaming
csv-export
backpressure
Intermediate
9 steps
java
@RestController @RequestMapping("/api/quotes") public class QuoteStreamController {
Streaming market quotes with Spring WebFlux
reactive-streams
backpressure
server-sent-events
Advanced
9 steps
typescript
export class Semaphore { private available: number; private readonly waiters: Array<() => void> = [];
Building an async Semaphore in TypeScript
concurrency
async-await
promises
Advanced
6 steps
go
type SensorReading struct { DeviceID string `json:"device_id" binding:"required"` Temperature float64 `json:"temperature"` RecordedAt time.Time `json:"recorded_at" binding:"required"`
Streaming NDJSON ingestion in Gin
streaming
batching
json-decoding
Advanced
10 steps
typescript
type JsonValue = Record<string, unknown> | unknown[]; export function parseJsonStream<T = JsonValue>( stream: ReadableStream<Uint8Array>,
Streaming JSON parsing with a depth counter
streams
parsing
state-machine
Advanced
9 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
javascript
async function mapWithConcurrency(items, limit, worker) { const results = new Array(items.length); let nextIndex = 0;
Bounded-concurrency async map in JavaScript
concurrency
async-await
promises
Intermediate
7 steps
javascript
const fs = require('fs'); const path = require('path'); router.get('/downloads/:name', (req, res, next) => {
Streaming file downloads in Express
streaming
backpressure
file-download
Advanced
9 steps