Skip to content
BERTREM is a Ruby EventMachine BERT-RPC client and server library.
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


By Benjamin Black (

BERTREM is a BERT-RPC client and server implementation that uses an EventMachine server to accept incoming connections, and then delegates the request to loadable Ruby handlers. BERTREM is derived from Ernie, by Tom Preston-Warner.

See the full BERT-RPC specification at

BERTREM currently supports the following BERT-RPC features:

  • call requests
  • cast requests


$ gem install bertrem -s

Example Handler

A simple Ruby module for use in a BERTREM server:

require 'bertrem'

module Calc
  def add(a, b)
    a + b

Example Server

A simple BERTREM server using the Calc module defined above:

require 'eventmachine'
require 'bertrem' {
  BERTREM::Server.expose(:calc, Calc)
  svc = BERTREM::Server.start('localhost', 9999)


You can have logging sent to a file by adding these lines to your handler:


This will log startup info, requests, and error messages to the log. Choosing Logger::DEBUG will include the response (be careful, doing this can generate very large log files).

Using the BERTRPC gem to make calls to BERTREM

The BERTREM client supports persistent connections, so you can send multiple requests over the same service connection and responses will return in the order the requests were sent:

require 'eventmachine'
require 'bertrem' {
  client = BERTREM::Client.service('localhost', 9999, true)
  rpc =, 2)
  rpc.callback { |res|
    puts "Got response! -> #{res}"

  rpc =, 2)
  rpc.callback { |res|
    puts "Got response! -> #{res}"
# Got response! -> 8
# Got response! -> 4

Alternatively, you can make BERT-RPC calls from Ruby with the BERTRPC gem:

require 'bertrpc'

svc ='localhost', 8000), 2)
# => 3


If you'd like to hack on BERTREM, start by forking my repo on GitHub:

To get all of the dependencies, install the gem first

The best way to get your changes merged back into core is as follows:

  1. Clone down your fork
  2. Create a topic branch to contain your change
  3. Hack away
  4. Add tests and make sure everything still passes by running rake
  5. If you are adding new functionality, document it in the
  6. Do not change the version number, I will do that on my end
  7. If necessary, rebase your commits into logical chunks, without errors
  8. Push the branch up to GitHub
  9. Send me (b) a pull request for your branch


Copyright (c) 2009 Benjamin Black. See LICENSE for details.

You can’t perform that action at this time.