0.0
No commit activity in last 3 years
No release in over 3 years
BERT::Client is a threadsafe BERT-RPC client with support for persistent connections and SSL
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

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

Option Default value Description
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