class Consul::Async::RemoteResource

Class to handle the retrival of a Remote resource (such a JSON API)

Public Class Methods

new(endpoints_manager) click to toggle source
# File lib/consul/async/consul_template.rb, line 28
def initialize(endpoints_manager)
  @endp_manager = endpoints_manager
end

Public Instance Methods

as_json(url, default_value, refresh_delay_secs: 10, **opts) click to toggle source
# File lib/consul/async/consul_template.rb, line 32
def as_json(url, default_value, refresh_delay_secs: 10, **opts)
  conf = JSONConfiguration.new(url: url, min_duration: refresh_delay_secs, retry_on_non_diff: refresh_delay_secs, **opts)
  endpoint_id = url + opts.to_json
  @endp_manager.create_if_missing(url, {}, endpoint_id: endpoint_id) do
    if default_value.is_a?(Array)
      ConsulTemplateJSONArray.new(JSONEndpoint.new(conf, url, default_value))
    else
      ConsulTemplateJSONObject.new(JSONEndpoint.new(conf, url, default_value))
    end
  end
end