class Iglu::Registries::HttpRegistryRef

Public Class Methods

new(config, uri) click to toggle source
# File lib/iglu-client/registries.rb, line 36
def initialize(config, uri)
  @config = config
  @class_priority = 100
  @descriptor = "HTTP"

  @uri = uri
end

Public Instance Methods

lookup_schema(schema_key, max_retries = 3) click to toggle source
# File lib/iglu-client/registries.rb, line 44
def lookup_schema(schema_key, max_retries = 3)
  schema_uri = "#{@uri}/schemas/#{schema_key.as_path}"
  times_retried = 0

  begin
    response = HTTParty.get(schema_uri, timeout: 3)
  rescue SocketError => _
    raise IgluError.new "Iglu registry #{config.name} is not available"
  rescue Net::ReadTimeout => e
    if times_retried < max_retries
      times_retried += 1
      retry
    else
      raise e
    end
  end

  if response.code == 200
    JSON::parse(response.body)
  else
    nil
  end
end