Module: Consulkit::Defaults

Defined in:
lib/consulkit/defaults.rb

Overview

Default configuration options for the Consulkit singleton and individual Client instances.

Constant Summary collapse

HTTP_ADDR =
'http://localhost:8500'
HTTP_TOKEN =
nil
MIDDLEWARE =
Faraday::RackBuilder.new do |builder|
  retry_exceptions = Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Consulkit::Error::Server]

  builder.use(Faraday::Request::Json)
  builder.use(Faraday::Response::Json)
  builder.use(Faraday::Retry::Middleware, exceptions: retry_exceptions)
  builder.use(Consulkit::Middleware::RaiseError)

  builder.adapter Faraday.default_adapter
end

Class Method Summary collapse

Class Method Details

.connection_optionsObject



28
29
30
# File 'lib/consulkit/defaults.rb', line 28

def connection_options
  {}
end

.http_addrObject



32
33
34
# File 'lib/consulkit/defaults.rb', line 32

def http_addr
  ENV.fetch('CONSUL_HTTP_ADDR', HTTP_ADDR)
end

.http_tokenObject



36
37
38
# File 'lib/consulkit/defaults.rb', line 36

def http_token
  ENV.fetch('CONSUL_HTTP_TOKEN', HTTP_TOKEN)
end

.middlewareObject



40
41
42
# File 'lib/consulkit/defaults.rb', line 40

def middleware
  MIDDLEWARE
end