Class: TCCE::Consul
- Inherits:
-
Object
- Object
- TCCE::Consul
- Defined in:
- lib/tcce/consul.rb
Instance Attribute Summary collapse
-
#kv_path ⇒ Object
Returns the value of attribute kv_path.
Instance Method Summary collapse
-
#get(inflate = true) ⇒ String
Query the
kv_pathfrom consul. -
#initialize(url, acl_token, kv_path, ca_file = nil) ⇒ Consul
constructor
A new instance of Consul.
Constructor Details
#initialize(url, acl_token, kv_path, ca_file = nil) ⇒ Consul
Returns a new instance of Consul.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tcce/consul.rb', line 13 def initialize(url, acl_token, kv_path, ca_file = nil) self.kv_path = kv_path Diplomat.configure do |config| # Set up a custom Consul URL config.url = url # Connect into consul with custom access token (ACL) config.acl_token = acl_token # Set extra Faraday configuration options config. = { ssl: { version: :TLSv1_2, ca_file: ca_file } } end end |
Instance Attribute Details
#kv_path ⇒ Object
Returns the value of attribute kv_path.
7 8 9 |
# File 'lib/tcce/consul.rb', line 7 def kv_path @kv_path end |
Instance Method Details
#get(inflate = true) ⇒ String
Query the kv_path from consul
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/tcce/consul.rb', line 33 def get(inflate = true) # Query object from consul consul_object = Diplomat::Kv.get kv_path return consul_object unless inflate # Inflate with gzip object_stream = StringIO.new consul_object gzip_stream = Zlib::GzipReader.new object_stream gzip_stream.read end |