Class: Restify::Adapter::Typhoeus
- Includes:
- Logging
- 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.
- #queued? ⇒ Boolean
- #sync? ⇒ Boolean
Methods included from Logging
Methods inherited from Base
Constructor Details
#initialize(sync: false, **options) ⇒ Typhoeus
Returns a new instance of Typhoeus.
17 18 19 20 21 |
# File 'lib/restify/adapter/typhoeus.rb', line 17 def initialize(sync: false, **) @sync = sync @hydra = ::Typhoeus::Hydra.new(**) @mutex = Mutex.new end |
Instance Attribute Details
#sync ⇒ Object (readonly)
Returns the value of attribute sync.
10 11 12 |
# File 'lib/restify/adapter/typhoeus.rb', line 10 def sync @sync end |
Instance Method Details
#call_native(request, writer) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/restify/adapter/typhoeus.rb', line 27 def call_native(request, writer) @mutex.synchronize do logger.debug { "[#{request.object_id}] Queue request #{request}" } @hydra.queue convert(request, writer) @hydra.dequeue_many end sync? ? @hydra.run : thread.run end |
#queued? ⇒ Boolean
37 38 39 40 41 |
# File 'lib/restify/adapter/typhoeus.rb', line 37 def queued? @mutex.synchronize do @hydra.queued_requests.any? || @hydra.multi.easy_handles.count > 0 end end |
#sync? ⇒ Boolean
23 24 25 |
# File 'lib/restify/adapter/typhoeus.rb', line 23 def sync? @sync end |