Sha256: 6171ef3862f683d578f7c898791e6a020d6b6cf9002d0c67dba85f93e7e04ca8

Contents?: true

Size: 717 Bytes

Versions: 8

Compression:

Stored size: 717 Bytes

Contents

require 'forwardable'

module BigBrother
  class ClusterCollection
    extend Forwardable
    def_delegators :@clusters, :[], :[]=, :size, :clear

    def initialize
      @clusters = {}
    end

    def config(new_clusters)
      new_clusters.each do |cluster_name, cluster|
        if @clusters.key?(cluster_name)
          @clusters[cluster_name] = cluster.incorporate_state(@clusters[cluster_name])
        else
          @clusters[cluster_name] = cluster
        end
      end
    end

    def running
      @clusters.values.select(&:monitored?)
    end

    def stopped
      @clusters.values.reject(&:monitored?)
    end

    def ready_for_check
      @clusters.values.select(&:needs_check?)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
big_brother-0.6.6 lib/big_brother/cluster_collection.rb
big_brother-0.6.5 lib/big_brother/cluster_collection.rb
big_brother-0.6.4 lib/big_brother/cluster_collection.rb
big_brother-0.6.3 lib/big_brother/cluster_collection.rb
big_brother-0.6.2 lib/big_brother/cluster_collection.rb
big_brother-0.6.1 lib/big_brother/cluster_collection.rb
big_brother-0.6.0 lib/big_brother/cluster_collection.rb
big_brother-0.5.0 lib/big_brother/cluster_collection.rb