Class: Teamd::Discover::Registry
- Inherits:
-
Object
- Object
- Teamd::Discover::Registry
- Defined in:
- lib/teamd/discover/registry.rb
Instance Method Summary collapse
- #add(cluster) ⇒ Object
- #find(c) ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #pack ⇒ Object
- #remove(matching_property) ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
6 7 8 9 10 11 |
# File 'lib/teamd/discover/registry.rb', line 6 def initialize @clusters ||= [] add_cluster_from_environment add_clusters_from_files "/etc/teamd/config*" add_clusters_from_files "/run/teamd/config" end |
Instance Method Details
#add(cluster) ⇒ Object
12 13 14 15 |
# File 'lib/teamd/discover/registry.rb', line 12 def add cluster STDERR.write "Adding Cluster with token: #{cluster.token} and name: #{cluster.name}\n" @clusters << cluster unless find cluster end |
#find(c) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/teamd/discover/registry.rb', line 21 def find c @clusters.each do |d| return true if d.name == c.name return true if d.token == c.token end false end |
#pack ⇒ Object
28 29 30 31 32 |
# File 'lib/teamd/discover/registry.rb', line 28 def pack @clusters.collect do |cluster| [cluster.name,cluster.token] end.to_h end |
#remove(matching_property) ⇒ Object
16 17 18 19 20 |
# File 'lib/teamd/discover/registry.rb', line 16 def remove matching_property @clusters.delete_if do |cluster| [cluster.name,cluster.token].include? matching_property end end |