pipe
pipe
Pipe provides reader and writer IOs, similar to IO.pipe. The main difference is that IO.pipe uses kernel-level file descriptors, but Pipe::Reader and Pipe::Writer live entirely in user-space. This avoids consuming file descriptors on systems where they are limited and ends up being much lighter weight.
Installation
-
Add the dependency to your
shard.yml:dependencies: pipe: github: jgaskins/pipe -
Run
shards install
Usage
require "pipe"
reader, writer = Pipe.create
spawn do
# Avoid generating the entire JSON blob in RAM
JSON.build writer do |json|
json.array do
10_000_000.times do |i|
json.scalar i
end
end
end
ensure
writer.close
end
HTTP::Client.post "http://localhost:3000/data", body: reader
Contributing
- Fork it (https://github.com/jgaskins/pipe/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Jamie Gaskins - creator and maintainer
Repository
pipe
Owner
Statistic
- 1
- 0
- 0
- 0
- 0
- 2 days ago
- January 7, 2026
License
MIT License
Links
Synced at
Fri, 09 Jan 2026 10:39:50 GMT
Languages