Each All the Way Down: How Ruby Enumerators Power Streaming...
summary
Explains why gRPC Ruby requires an Enumerator rather than just any Enumerable: gRPC calls each with a block to start network sends so returning an Array forces full materialization (imagine buffering a billion items) and delays streaming, while an enumerator delays execution and enables external iteration and backpressure. Shows concrete code patterns: custom each, enum_for / enumerator_new, how server and client streams map to the same enumerator contract over HTTP/2 and Protocol Buffers, and that the approach works for interleaved production and consumption.
AI-written summary · about
chapters (14)
- 0:00Introduction
- 1:25RPCs and gRPC explained
- 3:51gRPC streaming patterns
- 5:19gRPC Ruby streaming code
- 7:47Simplified gRPC example
- 8:48Ruby Enumerable module
- 11:57Ruby enumerators matter
- 12:59Internal vs external iteration
- 16:32gRPC needs server enumerator
- 19:48Arrays vs enumerators test
- 21:56No block case handling
- 22:17Client side stream consuming
- 24:46gRPC Ruby iteration patterns
- 26:55Summary
related talks
33mEnumberable's Ugly Cousin
11mEnumerable's Ugly Cousin
33mThe Enumerable Module or How I fell in Love with Ruby
31mEach: A Brief History of Iteration
05mStreaming data transformations with Ruby
45mEnumerable for Fun & Profit
34mActors in Ruby! Why let Elixir have all the fun?
19mGraphQL IRL: Pitfalls, Surprises and Successes
