Class: HttpEventStore::Api::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/http_event_store/api/connection.rb

Constant Summary collapse

APP_JSON =
'application/json'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(endpoint) ⇒ Connection

Returns a new instance of Connection.


6
7
8
# File 'lib/http_event_store/api/connection.rb', line 6

def initialize(endpoint)
  @endpoint = endpoint
end

Instance Method Details

#callObject


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/http_event_store/api/connection.rb', line 10

def call
  Faraday.new(
      url: endpoint.url,
  ) do |builder|
    builder.request :retry, max: 4, interval: 0.05,
                     interval_randomness: 0.5, backoff_factor: 2
    builder.adapter Faraday.default_adapter
    builder.response :json, content_type: APP_JSON
    builder.response :mashify
    builder.use ErrorsHandler
  end
end