Class: MCollective::Util::Playbook::DataStores::Base
- Inherits:
-
Object
- Object
- MCollective::Util::Playbook::DataStores::Base
- Defined in:
- lib/mcollective/util/playbook/data_stores/base.rb
Direct Known Subclasses
ConsulDataStore, EnvironmentDataStore, EtcdDataStore, FileDataStore, ShellDataStore
Instance Method Summary collapse
-
#delete(key) ⇒ Object
Deletes a key from a data store.
-
#from_hash(properties) ⇒ Base
Parse the data store properties as supplied by the playbook.
-
#initialize(name, playbook) ⇒ Base
constructor
A new instance of Base.
-
#lock(key, timeout) ⇒ Object
Locks a specific lock in the store.
-
#members(key) ⇒ Array<String>
Finds the members in a service.
-
#prepare ⇒ Object
Prepares the store for use.
-
#read(key) ⇒ String
Reads a key from a data store.
-
#release(key) ⇒ Object
Release a lock found in the store.
-
#startup_hook ⇒ Object
Start up processing.
-
#validate_configuration! ⇒ Object
Validate store properties created using from_hash.
-
#write(key, value) ⇒ Object
Writes a value to the key in a data store.
Constructor Details
#initialize(name, playbook) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 |
# File 'lib/mcollective/util/playbook/data_stores/base.rb', line 6 def initialize(name, playbook) @playbook = playbook @name = name startup_hook end |
Instance Method Details
#delete(key) ⇒ Object
deleting non existing data should not raise an error
Deletes a key from a data store
74 75 76 |
# File 'lib/mcollective/util/playbook/data_stores/base.rb', line 74 def delete(key) raise(StandardError, "delete not implemented in %s" % [self.class], caller) end |
#from_hash(properties) ⇒ Base
Parse the data store properties as supplied by the playbook
33 34 35 36 37 38 39 |
# File 'lib/mcollective/util/playbook/data_stores/base.rb', line 33 def from_hash(properties) @properties = properties validate_configuration! self end |
#lock(key, timeout) ⇒ Object
when the lock does not exist it should be created
Locks a specific lock in the store
56 57 58 |
# File 'lib/mcollective/util/playbook/data_stores/base.rb', line 56 def lock(key, timeout) raise(StandardError, "lock not implemented in %s" % [self.class], caller) end |
#members(key) ⇒ Array<String>
Finds the members in a service
65 66 67 |
# File 'lib/mcollective/util/playbook/data_stores/base.rb', line 65 def members(key) raise(StandardError, "members not implemented in %s" % [self.class], caller) end |
#prepare ⇒ Object
Prepares the store for use
Here you can do things like connect to data bases, set up pools etc
22 |
# File 'lib/mcollective/util/playbook/data_stores/base.rb', line 22 def prepare; end |
#read(key) ⇒ String
Reads a key from a data store
92 93 94 |
# File 'lib/mcollective/util/playbook/data_stores/base.rb', line 92 def read(key) raise(StandardError, "read not implemented in %s" % [self.class], caller) end |
#release(key) ⇒ Object
when the lock does not exist it should not raise an error
Release a lock found in the store
46 47 48 |
# File 'lib/mcollective/util/playbook/data_stores/base.rb', line 46 def release(key) raise(StandardError, "release not implemented in %s" % [self.class], caller) end |
#startup_hook ⇒ Object
Start up processing
Implementations should not create a #initialize instead they should have this hook which will be called once initialization is done
17 |
# File 'lib/mcollective/util/playbook/data_stores/base.rb', line 17 def startup_hook; end |
#validate_configuration! ⇒ Object
Validate store properties created using from_hash
27 |
# File 'lib/mcollective/util/playbook/data_stores/base.rb', line 27 def validate_configuration!; end |
#write(key, value) ⇒ Object
Writes a value to the key in a data store
83 84 85 |
# File 'lib/mcollective/util/playbook/data_stores/base.rb', line 83 def write(key, value) raise(StandardError, "write not implemented in %s" % [self.class], caller) end |