Skip to content

Instantly share code, notes, and snippets.

View aliasdhacker's full-sized avatar

Andrew aliasdhacker

View GitHub Profile
// socket -> reader -> N parsers -> batcher -> flushCh ->dbWriters -> pgCOPY
//
// Backpressure policy: prefer drop over OOM.
// Channel sends from reader and parser are non-blocking;
// dropped items bump a counter.
// Batcher->writers is
// blocking so pressure propagates upstream and is shed at the cheapest layer.
//
// Packet layout (28 bytes, big-endian):
// [0:8] device_id uint64
package main
import (
"encoding/binary"
"flag"
"log"
"math"
"math/rand"
"net"
"sync"