Class: Artemis::Adapters::NetHttpPersistentAdapter

Inherits:
NetHttpAdapter show all
Defined in:
lib/artemis/adapters/net_http_persistent_adapter.rb

Constant Summary

Constants inherited from AbstractAdapter

AbstractAdapter::DEFAULT_HEADERS, AbstractAdapter::EMPTY_HEADERS

Instance Attribute Summary collapse

Attributes inherited from AbstractAdapter

#pool_size, #service_name, #timeout

Instance Method Summary collapse

Methods inherited from NetHttpAdapter

#execute, #multiplex

Methods inherited from AbstractAdapter

#execute, #headers

Constructor Details

#initialize(uri, service_name:, timeout:, pool_size:, adapter_options: {}) ⇒ NetHttpPersistentAdapter

Returns a new instance of NetHttpPersistentAdapter.



27
28
29
30
31
32
33
34
35
36
# File 'lib/artemis/adapters/net_http_persistent_adapter.rb', line 27

def initialize(uri, service_name: , timeout: , pool_size: , adapter_options: {})
  super

  @raw_connection = Net::HTTP::Persistent.new(name: service_name, pool_size: pool_size)
  @raw_connection.open_timeout = timeout
  @raw_connection.read_timeout = timeout
  @raw_connection.idle_timeout = 30.minutes.to_i # TODO: Make it configurable

  @_connection = ConnectionWrapper.new(@raw_connection, uri)
end

Instance Attribute Details

#_connectionObject (readonly)

Returns the value of attribute _connection.



25
26
27
# File 'lib/artemis/adapters/net_http_persistent_adapter.rb', line 25

def _connection
  @_connection
end

#raw_connectionObject (readonly)

Returns the value of attribute raw_connection.



25
26
27
# File 'lib/artemis/adapters/net_http_persistent_adapter.rb', line 25

def raw_connection
  @raw_connection
end

Instance Method Details

#connectionObject

Public: Extension point for subclasses to customize the Net:HTTP client

Returns a Net::HTTP object



41
42
43
# File 'lib/artemis/adapters/net_http_persistent_adapter.rb', line 41

def connection
  _connection
end