Class: Gorynich::Fetchers::ConsulSecure

Inherits:
Object
  • Object
show all
Defined in:
lib/gorynich/fetchers/consul_secure.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(storage:, file_path:, **opts) ⇒ ConsulSecure

Returns a new instance of ConsulSecure.



6
7
8
9
10
# File 'lib/gorynich/fetchers/consul_secure.rb', line 6

def initialize(storage:, file_path:, **opts)
  @storage = storage
  @file_path = file_path
  @consul_opts = opts
end

Instance Attribute Details

#consul_optsObject (readonly)

Returns the value of attribute consul_opts.



4
5
6
# File 'lib/gorynich/fetchers/consul_secure.rb', line 4

def consul_opts
  @consul_opts
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



4
5
6
# File 'lib/gorynich/fetchers/consul_secure.rb', line 4

def file_path
  @file_path
end

#storageObject (readonly)

Returns the value of attribute storage.



4
5
6
# File 'lib/gorynich/fetchers/consul_secure.rb', line 4

def storage
  @storage
end

Instance Method Details

#fetchObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/gorynich/fetchers/consul_secure.rb', line 12

def fetch
  cfg = Consul.new(storage: storage, **consul_opts).fetch
  return from_file if cfg.empty?

  save_to_file(cfg)

  cfg
rescue ::StandardError
  from_file
end