This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "encoding/binary" | |
| "flag" | |
| "log" | |
| "math" | |
| "math/rand" | |
| "net" | |
| "sync" |