Skip to content

Instantly share code, notes, and snippets.

@laser
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laser/7ee4ef958b4e5904aa5e to your computer and use it in GitHub Desktop.
Save laser/7ee4ef958b4e5904aa5e to your computer and use it in GitHub Desktop.
Batch Client - Ruby
#!/usr/bin/env ruby
require 'barrister'
trans = Barrister::HttpTransport.new("http://localhost:3000/v1/todos")
client = Barrister::Client.new(trans)
batch = client.start_batch()
batch.TodoManager.createTodo({ 'title' => 'Call Mom', 'completed' => false })
batch.TodoManager.createTodo({ 'title' => 'Call Dad', 'completed' => false })
batch.TodoManager.createTodo({ 'title' => 'Wash car', 'completed' => false })
batch.TodoManager.createTodo({ 'title' => 'Eat Ham', 'completed' => false })
result = batch.send
result.each do |r|
# either r.error or r.result will be set
if r.error
# r.error is a Barrister::RpcException, so you can raise it if desired
puts "err.code=#{r.error.code}"
else
# result from a successful call
puts r.result
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment