Code Explainers

Code explainers tagged #channels

go
package streaming
 
import (
	"bufio"

Streaming NDJSON logs over HTTP in Go

http-streaming channels select
Advanced 10 steps
go
func (w *Watcher) resetDebounce(d time.Duration) {
	if !w.timer.Stop() {
		select {
		case <-w.timer.C:

Debouncing a stream of events in Go

debounce timers channels
Advanced 7 steps
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
go
func StreamLogs(c *gin.Context) {
	path := c.Query("file")
	if path == "" {
		c.JSON(http.StatusBadRequest, gin.H{"error": "missing file parameter"})

Streaming a live log tail with SSE in Gin

server-sent-events streaming channels
Advanced 10 steps
go
package logtail
 
import (
	"bufio"

How a tail -f follower works in Go

io context channels
Intermediate 10 steps
go
func (h *ExportHandler) StreamExport(c *gin.Context) {
	datasetID := c.Param("id")
 
	ctx := c.Request.Context()

Streaming NDJSON progress with Gin

streaming goroutines channels
Advanced 8 steps
go
package handler
 
type flightResult struct {
	status int

Deduping in-flight requests in Gin

middleware concurrency deduplication
Advanced 9 steps
rust
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
 

Running work with a timeout in Rust

concurrency channels timeout
Intermediate 7 steps
go
package sse
 
import (
	"encoding/json"

Server-Sent Events streaming in Go

server-sent-events channels http-streaming
Intermediate 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 crossbeam_channel::{Receiver, Sender, select, tick};
use std::time::Duration;
 
pub enum Command {

A channel-driven worker loop in Rust

channels select message-passing
Intermediate 9 steps
rust
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::thread;
 

A round-robin worker pool in Rust

concurrency thread-pool channels
Intermediate 7 steps
java
@Configuration
@EnableIntegration
public class OrderProcessingFlow {
 

Building an order pipeline with Spring Integration

messaging pipeline enterprise integration patterns
Intermediate 9 steps
rust
use std::collections::HashSet;
use std::path::PathBuf;
use std::time::Duration;
 

Debouncing filesystem events in async Rust

debounce async channels
Advanced 7 steps
go
package ratelimit
 
import (
	"context"

A token bucket rate limiter in Go

rate-limiting concurrency goroutines
Intermediate 7 steps
go
package scheduler
 
import (
	"context"

A context-aware heartbeat ticker in Go

concurrency channels context
Intermediate 5 steps
go
package pipeline
 
import "sync"
 

The fan-in pattern in Go channels

concurrency channels fan-in
Advanced 8 steps
go
package pipeline
 
import (
	"context"

A cancelable worker pool in Go

concurrency channels worker-pool
Advanced 8 steps