A data pipeline with bounded concurrency, a quality gate and a custom middleware.
Inspectcounts the invalid records and keeps the input it judged.Ifcleans the input when more than a tenth of it is invalid.Each(8, transform)processes the records, at most eight at a time.summarisecounts the categories and the throughput, and the report is written toresults.json.- The last part runs the same batch on uncleaned input, to show the errors
that
Eachjoins together.
cd examples/advanced
go run main.gotimedis a custom middleware.Middleware[I, O]is a function from a step to a step, so writing one needs nothing from the library. A step holds no state of its own, so the durations go to a collector you can read.Eachis a function, not a method. A method returningStep[[]I, []O]would make the compiler instantiateStep[[][]I, [][]O], and so on without end.Eachruns every element to the end and returns every error joined witherrors.Join. Nothing is dropped in silence.- The export uses
encoding/json/v2. The options keep the duration format and the sorted map order that v1 gave.
results.json