Repository is archived
No release in over 3 years
Low commit activity in last 3 years
A lean Ruby client for the MessagePack-RPC protocol.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0
>= 0

Runtime

 Project Readme

MsgpackRpcClient CircleCI

A lean Ruby client for the MessagePack-RPC protocol

Use this gem to achieve reliable, fault-tolerant RPC with your microservices.

Differences from the "official" implementation (the msgpack-rpc gem)

The official implementation:

  • depends on the cool.io gem, labeled "retired" on the homepage.
  • does not re-establish connections.
  • designed to be asynchronous
  • displayed instability under high load in production
  • does not support JRuby

This implementation:

  • has no dependencies but the msgpack gem
  • is under 200 lines in one class
  • automatically re-establishes connections in the case of inevitable network errors, service restarts, deploys, and so on.
  • supports SSL
  • threadsafe
  • reliable
  • high load tested
  • used in production, with up to a 1000 requests per second in a single frontend request.
  • supports MRI from version 1.9.3 - for those who have a huge legacy app that you're dying to factor into microservices!
  • supports JRuby (but see installation notes)

However, this implementation does NOT support asynchronous calls - if you require this feature, it is not for you. However, from my experience, almost no Ruby applications require asynchronous communication.

Installation

Add this line to your application's Gemfile:

gem 'msgpack_rpc_client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install msgpack_rpc_client

JRuby

There was a bug in the jruby msgpack implementation that was fixed in this PR. Until it's released as a stable version (>1.0.0), you need to use the HEAD version of the msgpack gem:

gem 'msgpack_rpc_client'
# TODO remove once msgpack v1.0.1 or later is released
gem 'msgpack', git: 'https://github.com/msgpack/msgpack-ruby.git'

Usage

require 'msgpack_rpc_client'

client = MsgpackRpcClient.new(host: '127.0.0.1', port: 12345)
response = client.call('HelloWorld', name: 'Ruby')
# You should re-use the client for all subsequent calls to the same server.
# It's never necessary to re-connect, and the client is threadsafe.

See the examples directory for a complete server-client example.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/brightbytes/msgpack_rpc_client.

License

The gem is available as open source under the terms of the MIT License.