Solid Objects integrates Cloudflare's Durable Objects programming model with Ruby on Rails, allowing for addressable objects with durable state and seamless reactivity. It operates on existing databases without additional services, making it easier to implement durable programming principles in standard Rails applications.
Solid Objects: A Ruby on Rails Implementation of Cloudflare's Durable Objects
Solid Objects adapts the Durable Objects programming model for Ruby on Rails, enabling developers to incorporate addressable objects, durable state, serialized execution, alarms, and live client interactions into their regular Rails applications. Unlike traditional setups that may require Redis, a Cloudflare account, or an external actor service, Solid Objects operates directly with the existing MySQL, PostgreSQL, or SQLite database of the application, streamlining development and integration.
class Counter < SolidObjects::Actor
attribute :value, default: 0
def increment(amount: 1)
self.value += amount
end
end
# Creating a reference to the Counter actor
counter = Counter.ref("global")
count = counter.increment(amount: 5) # Synchronous call
current_count = counter.value # Accessing the current value
Every interaction with an actor is queued, ensuring that commands are handled in the order they are received. Solid Objects utilizes fencing to protect data integrity during concurrent operations, thereby preventing stale state from impacting new executions.
Solid Objects supports per-object alarms for timing operations and managing callbacks, while integrating seamlessly with Action Cable and Turbo for real-time updates, allowing applications to push data to clients effortlessly.
Solid Objects brings the advantages of a sophisticated actor model without the complexity of external services, making it an ideal choice for developers looking to enhance their Rails applications with stateful objects that are both powerful and easy to use. The system is designed to be both robust and developer-friendly, aiming for production-readiness while providing extensive documentation and support for its features.
For more information on getting started, best practices, and detailed API usage, refer to the Solid Objects documentation.
Solid Objects is an innovative approach to integrating Cloudflare's Durable Objects into Ruby on Rails applications, providing essential features that enhance the capability of state management and real-time data processing. This project is still in its early release phase, and feedback is appreciated to improve its functionality and reliability.
No comments yet.
Sign in to be the first to comment.