Module: We::Call::Connection

Extended by:
Connection
Included in:
Connection
Defined in:
lib/we/call/connection.rb

Defined Under Namespace

Classes: MissingApp, MissingEnv, MissingOpenTimeout, MissingTimeout

Constant Summary collapse

OPEN_TIMEOUT =

If your network isn’t stable enough to get a sign of life in 1s then you should look into that Or override this default on creating the connection.

1
DEFAULT_ADAPTER_CLASS =

We use typhoeus instead of default NetHTTP so we can control how many retries are made github.com/lostisland/faraday/issues/612

Faraday::Adapter::Typhoeus
DEFAULT_ADAPTER =
:typhoeus
DEFAULT_RETRY_OPTIONS =
{
  max: 3,
  interval: 1,
  exceptions: [Faraday::ConnectionFailed, Faraday::TimeoutError]
}
QueryableBuilder =
Class.new(Faraday::RackBuilder) do
  def adapter?
    @adapter || false
  end

  def adapter(key, *args, &block)
    super
    @adapter = key
  end

  def get_adapter
    @adapter || DEFAULT_ADAPTER
  end
end

Instance Method Summary collapse

Instance Method Details

#new(host:, timeout: nil, open_timeout: OPEN_TIMEOUT, app: guess_app, env: guess_env, retry_options: {}) {|Faraday| ... } ⇒ Object

Parameters:

  • host (Object)
  • timeout (Integer) (defaults to: nil)
  • open_timeout (Integer) (defaults to: OPEN_TIMEOUT)
  • app (String) (defaults to: guess_app)
  • env (String) (defaults to: guess_env)

Yield Parameters:

  • Faraday (Faraday::Connection)

    connection object is yielded to a block



49
50
51
52
53
54
55
56
57
# File 'lib/we/call/connection.rb', line 49

def new(host:, timeout: nil, open_timeout: OPEN_TIMEOUT, app: guess_app, env: guess_env, retry_options: {}, &block)
  @host = host
  @retry_options = retry_options
  @app = app or raise_missing_app!
  @env = env or raise_missing_env!
  @timeout = timeout or raise_missing_timeout!
  @open_timeout = open_timeout or raise_missing_open_timeout!
  create(&block)
end