Class: Iglu::Registries::HttpRegistryRef

Inherits:
RegistryRef show all
Defined in:
lib/iglu-client/registries.rb

Instance Attribute Summary

Attributes inherited from RegistryRef

#class_priority, #config, #descriptor

Instance Method Summary collapse

Methods inherited from RegistryRef

#vendor_matched

Constructor Details

#initialize(config, uri) ⇒ HttpRegistryRef

Returns a new instance of HttpRegistryRef.



36
37
38
39
40
41
42
# File 'lib/iglu-client/registries.rb', line 36

def initialize(config, uri)
  @config = config
  @class_priority = 100
  @descriptor = "HTTP"

  @uri = uri
end

Instance Method Details

#lookup_schema(schema_key, max_retries = 3) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# 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