Sha256: d6b144526aaa15b0172b541373ab1dd58b6c59b6fca9b600d4b37a7b4d1fa545
Contents?: true
Size: 1.3 KB
Versions: 4
Compression:
Stored size: 1.3 KB
Contents
require 'kirk' module Kirk class Client require 'kirk/client/group' require 'kirk/client/response' require 'kirk/client/request' require 'kirk/client/exchange' def self.client @client ||= new end def self.stop @client.stop if @client @client = nil end def self.group(opts = {}, &blk) client.group(opts, &blk) end %w(request head get post put delete).each do |method| class_eval <<-RUBY def self.#{method}(*args, &blk) client.#{method}(*args, &blk) end def #{method}(*args, &blk) g = group { |g| g.#{method}(*args, &blk) } g.responses.first end RUBY end def group(opts = {}, &blk) Group.new(self, opts).tap do |group| group.start(&blk) end end def initialize(opts = {}) @options = opts end def client @client ||= Jetty::HttpClient.new.tap do |client| client.set_connector_type(Jetty::HttpClient::CONNECTOR_SELECT_CHANNEL) client.set_thread_pool(thread_pool) if thread_pool client.start end end def process(request) client.send Exchange.build(request) end def stop client.stop end private def thread_pool @options[:thread_pool] end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
kirk-0.2.0.beta.7-java | lib/kirk/client.rb |
kirk-0.2.0.beta.6-java | lib/kirk/client.rb |
kirk-0.2.0.beta.5-java | lib/kirk/client.rb |
kirk-0.2.0.beta.4-java | lib/kirk/client.rb |