Guide
What dRuby is, how to install it, and how servers, clients and remote objects behave.
7 guide pages
- What is dRuby?
dRuby (DRb) lets one Ruby process call methods on objects that live in another. What it does, how a call travels, and when it fits.
- Installing dRuby: the drb gem and Ruby 3.4
drb was a default library and became a bundled gem in Ruby 3.4. When you need gem "drb" in your Gemfile and how to check it loads.
- A first dRuby server and client
Two short scripts: a server that publishes an object with DRb.start_service and a client that calls it through DRbObject.new_with_uri.
- Pass by value, pass by reference and DRbUndumped
dRuby copies objects it can marshal and sends a reference for the rest. How to tell which you get, and how DRb::DRbUndumped forces a reference.
- Callbacks and blocks: why the client needs DRb.start_service
A block or callback object passed to a dRuby server stays in the client and is called back over the network, so the client must run a service too.
- dRuby URIs and protocols: druby://, drbunix: and drbssl://
The three protocols that ship with dRuby, what each URI looks like, and which file to require for UNIX sockets and SSL.
- Threads, DRb.thread.join and keeping a server alive
A dRuby server runs in a background thread, so the script must wait on it with DRb.thread.join. Also: why front objects must be thread-safe.