Class: ConsulWatcher::Storage::Consul
- Inherits:
-
Object
- Object
- ConsulWatcher::Storage::Consul
- Includes:
- FlazmRubyHelpers::Class
- Defined in:
- lib/consul_watcher/storage/consul.rb
Overview
Consul storage for previous watch data
Instance Method Summary collapse
- #fetch ⇒ Object
- #get_filters ⇒ Object
-
#initialize(storage_config) ⇒ Consul
constructor
A new instance of Consul.
- #push(data) ⇒ Object
Constructor Details
#initialize(storage_config) ⇒ Consul
Returns a new instance of Consul.
14 15 16 17 |
# File 'lib/consul_watcher/storage/consul.rb', line 14 def initialize(storage_config) initialize_variables(storage_config) config_diplomat end |
Instance Method Details
#fetch ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/consul_watcher/storage/consul.rb', line 19 def fetch @logger.debug('fetching state from consul') data = Diplomat::Kv.get(cache_file_name) data = Zlib::Inflate.inflate(data) if @compress data rescue Diplomat::KeyNotFound '{}' end |
#get_filters ⇒ Object
33 34 35 |
# File 'lib/consul_watcher/storage/consul.rb', line 33 def get_filters { 'key_path' => [ cache_file_name ] } end |
#push(data) ⇒ Object
28 29 30 31 |
# File 'lib/consul_watcher/storage/consul.rb', line 28 def push(data) @logger.debug('pushing state to consul') Diplomat::Kv.put(cache_file_name, @compress ? Zlib::Deflate.deflate(data, Zlib::BEST_COMPRESSION) : data) end |