Avro_client is a project mainly written in RUBY and JAVASCRIPT, based on the View license.
An Avro client wrapper that encapsulates some common failover behavior. This is based on Evan Weaver's Thrift-Client [http://github.com/fauna/thrift_client].
avro_client
An Avro client wrapper that encapsulates some common failover behavior. This is based on Evan Weaver's Thrift-Client [http://github.com/fauna/thrift_client].
== License
Copyright 2010 Twitter, Inc. See included LICENSE file.
== Features
== Usage
Instantiate a client:
options = { :protocol => MAIL_PROTOCOL } client = AvroClient.new(["localhost:9091", "localhost:9090", "localhost:9092"], options)
You can then make calls to the server via the client instance as if was your Avro requestor. The connection will be opened lazily and methods will be proxied through.
avro.request("mail", params) or avro.mail(params)
Please note that the method name (e.g. "mail") cannot be "send".
On failures, the client will try the remaining servers in the list before giving up. See AvroClient for more.
== Installation
You need Ruby 1.8 or 1.9. If you have those, just run:
sudo gem install avro_client
== Examples
First start the server: ruby test/sample_server.rb
Run the script from another shell: ruby test/make_sample_script
Output from the server: $ ruby test/sample_server.rb Requests processed 1 Requests processed 2 Requests processed 3
Output from the script: $ ruby test/make_sample_script
[{"name"=>"Foo", "id"=>1, "maker"=>"Foobar"}, {"name"=>"Foo", "id"=>2, "maker"=>"Foobar"}, {"name"=>"Foo", "id"=>3, "maker"=>"Foobar"}, {"name"=>"Foo", "id"=>4, "maker"=>"Foobar"}, {"name"=>"Foo", "id"=>5, "maker"=>"Foobar"}]
[{"name"=>"default sample name", "id"=>1, "maker"=>"Foobar"}, {"name"=>"default sample name", "id"=>2, "maker"=>"Foobar"}]
"#
== Tests
ruby test/test_simple.rb -- This test forks a server process and sends avro requests to the server using avro client.
ruby test/test_multiple_servers.rb -- This test forks two servers and checks if avro requests are sent to both servers.