Class: Restify::Adapter::Typhoeus
- Defined in:
- lib/restify/adapter/typhoeus.rb
Constant Summary collapse
- DEFAULT_HEADERS =
{ 'Expect' => '', 'Transfer-Encoding' => '' }.freeze
Instance Attribute Summary collapse
-
#sync ⇒ Object
readonly
Returns the value of attribute sync.
Instance Method Summary collapse
- #call_native(request, writer) ⇒ Object
-
#initialize(sync: false, **options) ⇒ Typhoeus
constructor
A new instance of Typhoeus.
- #queue(request, writer) ⇒ Object
- #sync? ⇒ Boolean
Methods inherited from Base
Constructor Details
#initialize(sync: false, **options) ⇒ Typhoeus
Returns a new instance of Typhoeus.
15 16 17 18 19 20 21 |
# File 'lib/restify/adapter/typhoeus.rb', line 15 def initialize(sync: false, **) @queue = Queue.new @sync = sync @hydra = ::Typhoeus::Hydra.new(pipelining: true, **) start unless sync? end |
Instance Attribute Details
#sync ⇒ Object (readonly)
Returns the value of attribute sync.
8 9 10 |
# File 'lib/restify/adapter/typhoeus.rb', line 8 def sync @sync end |
Instance Method Details
#call_native(request, writer) ⇒ Object
36 37 38 |
# File 'lib/restify/adapter/typhoeus.rb', line 36 def call_native(request, writer) queue request, writer end |
#queue(request, writer) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/restify/adapter/typhoeus.rb', line 27 def queue(request, writer) if sync? @hydra.queue convert request, writer @hydra.run else @queue.push [request, writer] end end |
#sync? ⇒ Boolean
23 24 25 |
# File 'lib/restify/adapter/typhoeus.rb', line 23 def sync? @sync end |