Sha256: 60a6d79101a8b495379afbc3e61fc13debacaaa7c69972aabe2a36030e34fc54

Contents?: true

Size: 802 Bytes

Versions: 23

Compression:

Stored size: 802 Bytes

Contents

require 'rest-core'

YourClient = RC::Builder.client do
  use RC::DefaultSite , 'https://api.github.com/users/'
  use RC::JsonResponse, true
  use RC::CommonLogger, method(:puts)
  use RC::Cache       , nil, 3600
end

YourClient.pool_size = 5

client = YourClient.new(:cache => {})
p client.get('godfat') # cache miss
puts
p client.get('godfat') # cache hit

client.cache = false

puts "concurrent requests"
a = [client.get('godfat'), client.get('cardinalblue')]
puts "It's not blocking... but doing concurrent requests underneath"
p a.map{ |r| r['name'] } # here we want the values, so it blocks here
puts "DONE"

puts "callback"
client.get('godfat'){ |v| p v }
puts "It's not blocking... but doing concurrent requests underneath"
client.wait # we block here to wait for the request done
puts "DONE"

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rest-core-3.6.0 example/simple.rb
rest-core-3.5.92 example/simple.rb
rest-core-3.5.91 example/simple.rb
rest-core-3.5.9 example/simple.rb
rest-core-3.5.8 example/simple.rb
rest-core-3.5.7 example/simple.rb
rest-core-3.5.6 example/simple.rb
rest-core-3.5.5 example/simple.rb
rest-core-3.5.4 example/simple.rb
rest-core-3.5.3 example/simple.rb
rest-core-3.5.2 example/simple.rb
rest-core-3.5.1 example/simple.rb
rest-core-3.5.0 example/simple.rb
rest-core-3.4.1 example/simple.rb
rest-core-3.4.0 example/simple.rb
rest-core-3.3.3 example/simple.rb
rest-core-3.3.2 example/simple.rb
rest-core-3.3.1 example/simple.rb
rest-core-3.3.0 example/simple.rb
rest-core-3.2.0 example/simple.rb