Class: Restify::Adapter::Typhoeus

Inherits:
Base
  • Object
show all
Defined in:
lib/restify/adapter/typhoeus.rb

Constant Summary collapse

DEFAULT_HEADERS =
{
  'Expect' => '',
  'Transfer-Encoding' => ''
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#call

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, **options)
  @queue   = Queue.new
  @sync    = sync
  @hydra   = ::Typhoeus::Hydra.new(pipelining: true, **options)

  start unless sync?
end

Instance Attribute Details

#syncObject (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

Returns:

  • (Boolean)


23
24
25
# File 'lib/restify/adapter/typhoeus.rb', line 23

def sync?
  @sync
end