lib/consul/async/vault_endpoint.rb in consul-templaterb-1.5.3 vs lib/consul/async/vault_endpoint.rb in consul-templaterb-1.5.4
- old
+ new
@@ -27,11 +27,10 @@
@min_duration = min_duration
@max_retry_duration = max_retry_duration
@lease_duration_factor = lease_duration_factor
@paths = paths
@token = token
-
end
def ch(path, symbol)
sub = @paths[path.to_sym]
if sub && sub[symbol]
@@ -83,11 +82,10 @@
def json
@data_json = JSON.parse(data) if @data_json.nil?
@data_json
end
-
end
class VaultHttpResponse
attr_reader :response_header, :response, :error, :json
def initialize(http, override_nil_response = nil)
@@ -105,11 +103,11 @@
end
class VaultEndpoint
attr_reader :conf, :path, :http_method, :queue, :stats, :last_result, :enforce_json_200, :start_time, :default_value, :query_params
- def initialize(conf, path, http_method = 'GET', enforce_json_200 = true, query_params = {}, default_value = '{}', post_data ={})
+ def initialize(conf, path, http_method = 'GET', enforce_json_200 = true, query_params = {}, default_value = '{}', post_data = {})
@conf = conf.create(path)
@default_value = default_value
@path = path
@http_method = http_method
@queue = EM::Queue.new
@@ -121,11 +119,11 @@
@consecutive_errors = 0
@query_params = query_params
@post_data = post_data
@stopping = false
@stats = EndPointStats.new
- @last_result = VaultResult.new(VaultHttpResponse.new(nil, default_value), false, stats ,1)
+ @last_result = VaultResult.new(VaultHttpResponse.new(nil, default_value), false, stats, 1)
on_response { |result| @stats.on_response result }
on_error { |http| @stats.on_error http }
_enable_network_debug if conf.debug && conf.debug[:network]
fetch
queue.push 0
@@ -159,11 +157,11 @@
@stopping = true
end
private
- def build_request()
+ def build_request
res = {
head: {
'Accept' => 'application/json',
'X-Vault-Token' => conf.token
},
@@ -198,10 +196,10 @@
STDERR.puts "[ERROR][#{path}][#{http_method}] Code: #{http.response_header.status} #{_get_errors(http).join(' - ')} - Retry in #{retry_in}s #{stats.body_bytes_human}"
@consecutive_errors += 1
http_result = VaultHttpResponse.new(http, default_value)
EventMachine.add_timer(retry_in) do
yield
- queue.push()
+ queue.push
end
@e_callbacks.each { |c| c.call(http_result) }
end
def fetch