Class: Restify::Adapter::Typhoeus
- Includes:
- Logging
- Defined in:
- lib/restify/adapter/typhoeus.rb
Defined Under Namespace
Modules: EasyOverride Classes: Request
Constant Summary collapse
- DEFAULT_HEADERS =
{ 'Expect' => '', 'Transfer-Encoding' => '', }.freeze
- DEFAULT_OPTIONS =
{ followlocation: true, tcp_keepalive: true, tcp_keepidle: 5, tcp_keepintvl: 5, }.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: {}, **kwargs) ⇒ Typhoeus
constructor
A new instance of Typhoeus.
- #sync? ⇒ Boolean
Methods included from Logging
Methods inherited from Base
Methods included from Telemetry
Constructor Details
#initialize(sync: false, options: {}, **kwargs) ⇒ Typhoeus
Returns a new instance of Typhoeus.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/restify/adapter/typhoeus.rb', line 44 def initialize(sync: false, options: {}, **kwargs) @hydra = ::Typhoeus::Hydra.new(**kwargs) @hydra.extend(EasyOverride) @mutex = Mutex.new @options = DEFAULT_OPTIONS.merge() @queue = Queue.new @sync = sync @thread = nil super() end |
Instance Attribute Details
#sync ⇒ Object (readonly)
Returns the value of attribute sync.
12 13 14 |
# File 'lib/restify/adapter/typhoeus.rb', line 12 def sync @sync end |
Instance Method Details
#call_native(request, writer) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/restify/adapter/typhoeus.rb', line 61 def call_native(request, writer) req = convert(request, writer) if sync? @hydra.queue(req) @hydra.run else debug 'request:add', tag: request.object_id, method: request.method.upcase, url: request.uri, timeout: request.timeout @queue << convert(request, writer) thread.run unless thread.status end end |
#sync? ⇒ Boolean
57 58 59 |
# File 'lib/restify/adapter/typhoeus.rb', line 57 def sync? @sync end |