$ show boazsegev/iodine
Iodine is a high-performance concurrent web server for Ruby applications, built as a wrapper around the C-based facil.io framework. It provides native HTTP/WebSocket/Server-Sent Events support, Rack compliance for serving Ruby web applications, and a built-in Pub/Sub system with optional Redis scaling for horizontal distribution. The architecture follows a master-worker model using multiple processes and threads to handle thousands of concurrent connections, with critical networking components implemented in C for performance and Ruby bindings for developer productivity. Key features include static file serving with gzip and X-Sendfile support, a secure Mustache template engine with automatic HTML escaping, a fast JSON parser claiming 20-90% speed improvements over Ruby's standard library, and TLS support (though marked as having known issues for production use). The server integrates with Rack applications through a custom handler and provides upgrade hooks for WebSocket/SSE protocols via the Rack environment. Pub/Sub functionality uses an engine pattern allowing swap between internal cluster-based and external Redis backends. Entry points include the `exe/iodine` CLI executable and programmatic controls via `Iodine.listen`, `Iodine.start`, and `Iodine.stop`. Data flows involve HTTP requests parsed by the C-based HTTP processor, routed to Rack applications or static file handlers, with WebSocket connections upgraded via Rack's `env['rack.upgrade?']` mechanism. The Pub/Sub system operates independently for real-time messaging across processes or machines. External dependencies include the vendored facil.io C library, OpenSSL development headers for TLS support, and optionally the Redis gem for clustered Pub/Sub.
The LLM identified 3 files worth highlighting for reuse:
Provides a clean Ruby interface to a high-performance, secure Mustache template engine implemented in C. Demonstrates the pattern of wrapping native extensions for performance while maintaining a simple, idiomatic Ruby API. The class is self-contained with no dependencies on other Iodine modules, making it easily extractable for use in other Ruby projects requiring fast, XSS-safe templating.
Wraps a custom C JSON parser that claims 20-90% speed improvements over Ruby's standard JSON library, with additional support for hex numbers and comments. The implementation follows a clean wrapper pattern where the Ruby class solely handles argument marshaling and result conversion, delegating all parsing logic to the C extension. This isolation allows the component to be reused in other projects needing a fast JSON parser with minimal adaptation.
Defines an abstract Pub/Sub engine interface and a default cluster-based implementation, showcasing the strategy pattern for swappable messaging backends. The module cleanly separates concerns: the Ruby interface defines the contract (`subscribe`, `publish`, etc.) while specific engines (internal cluster, Redis) handle the implementation. This design allows applications to switch between single-machine and multi-machine Pub/Sub without code changes, demonstrating excellent architectural decoupling.