class Artemis::Adapters::AbstractAdapter

Constants

DEFAULT_HEADERS
EMPTY_HEADERS

Attributes

pool_size[R]
service_name[R]
timeout[R]

Public Class Methods

new(uri, service_name: , timeout: , pool_size: , adapter_options: {}) click to toggle source
Calls superclass method
# File lib/artemis/adapters/abstract_adapter.rb, line 18
def initialize(uri, service_name: , timeout: , pool_size: , adapter_options: {})
  raise ArgumentError, "url is required (given `#{uri.inspect}')" if uri.blank?

  super(uri) # Do not pass in the block to avoid getting #headers and #connection overridden.

  @service_name = service_name.to_s
  @timeout      = timeout
  @pool_size    = pool_size
end

Public Instance Methods

connection() click to toggle source

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

A subclass that inherits from AbstractAdapter should returns a Net::HTTP object or an object that responds to request that is given a Net::HTTP request object.

# File lib/artemis/adapters/abstract_adapter.rb, line 49
def connection
  raise "AbstractAdapter is an abstract class that can not be instantiated!"
end
execute(*) click to toggle source

Public: Make an HTTP request for GraphQL query.

A subclass that inherits from AbstractAdapter can override this method if it needs more flexibility for how it makes a request.

For more details, see +GraphQL::Client::HTTP#execute+.

Calls superclass method
# File lib/artemis/adapters/abstract_adapter.rb, line 41
def execute(*)
  super
end
headers(_context) click to toggle source

Public: Extension point for subclasses to set custom request headers.

Returns Hash of String header names and values.

# File lib/artemis/adapters/abstract_adapter.rb, line 31
def headers(_context)
  _context[:headers] || EMPTY_HEADERS
end