Skip to content

Latest commit

 

History

History
124 lines (110 loc) · 3.11 KB

README.md

File metadata and controls

124 lines (110 loc) · 3.11 KB

BERT::Client

BERT::Client is a threadsafe BERT-RPC client with support for persistent connections and SSL. It currently exposes BERT-RPC's cast and call.

This version is designed to work with modified ernie server that doesn't (as a contrary to linked ernie version) close connection after response.

Tested on ruby 1.9.2.

Dependancies

Requires BERT gem to be installed.

Requires Jeweler gem to be installed if you want to pack this library into it's own gem.

Usage

require 'bertclient'
client = BERT::Client.new(:host => 'localhost', :port => 9999)
client.call(:calc, :add, 1, 2)
#=> 3
client.call(:calc, :add, 5, 5)
#=> 10
client.call(:calc, :sub, 10, 5)
#=> 5

You can also use blocks to create ephemeral connections:

BERT::Client.new(opts) do |client|
  client.call(:auth, :authenticate, user, password)
  client.call(:calc, :add, 1, 2)
end

Available contructor arguments

OptionDefault valueDescription
host localhost Hostname of server that ernie server runs on.
port 9999 Port number on which ernie server listens on.
timeout 15 Currently socket connection doesn't respect this value. TODO: Fix it
gzip, gzip_threshold, gzip_accept_sent false, 1024, false [untested] These gzip-encoding related attributes have been introduced in original bertclient. I wasn't able to find any information concerning possible usage of gzip in bert/berp, so I'm not really sure whenever this works and/or is implemented correctly.
ssl false TODO
verify_ssl true TODO
encoding "utf-8"|nil Expected encoding for any string data returned by ernie. For this function working correctly, you have to use version of BERT that supports passing encoding type to decode function. There are a lot of forks of BERT that are doing just that, personally I'm using this one. If your BERT library doesn't support passing encoding to decode method, client would fallback to regular one-argument method of BERT.

TODO

  • Write tests
  • Package and publish the gem version