Evented HTTP toolkit for Ruby
Rity provides a rich toolkit for building custom services that communicate via HTTP. It can be used to build clients as well as servers, proxies and streaming APIs. Rity uses EventMachine's native proxying to let data completely bypass Ruby if possible, saving CPU time and increasing IO throughput.
gem install rity
The easiest way to get up and running with Rity is to serve your Rack app with it. Rity uses EventMachine to do evented networking and processing, thus doing any kind of IO or long-running computations in a blocking manner is uncool. Rity uses EM-Synchrony and Ruby 1.9's Fibers to cooperatively schedule the processing work against the event loop (similar to Goliath). If you're not yet familiar with the combination of EventMachine and Fibers, you should give Ilya Grigorik's introduction a read.
The following line represents the options of Rity's CLI and their defaults.
rity --rackup config.ru --bind 127.0.0.1 --port 3000
You can use the
--verbose options to suppress output or get
detailed debugging output, respectively. Shortcuts and more documentation of
the CLI can be found by typing
Building a server
Building a client
To do list
- Proxying via EM.enable_proxy
- Contents of env hash
- Headers with multiple values
- Implement Rack spec
- Rack Handler
- Support for keep-alive connections
- Investigate MVM support in JRuby/Rubinius/MRI
- Support for SPDY
- Investigate preforking and letting multiple EventMachine loops listen on a shared socket
- Support for X-Sendfile header
- Deamonizing & dropping privileges
Hacking on Rity
Get the source code
git clone https://github.com/lgierth/rity
Install development dependencies
Run the specs
bundle exec rake spec
Start a rackup server
bundle exec rity -r examples/simple_server.ru
Preview API documentation
bundle exec yard server
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a future version unintentionally.
- Send me a pull request. Bonus points for topic branches.
- API documentation: rubydoc.info/gems/rity
- Source code: github.com/lgierth/rity
- Bugs and feature requests: github.com/lgierth/rity/issues
- Continuous Integration: travis-ci.org/#!/lgierth/rity
Rity is released under the terms of the MIT License, see the included LICENSE file.