Sha256: 93ccd8f745637aa9ca25195cbeeaca6d0a7b55f080b33a503fe92dd108406bb2

Contents?: true

Size: 932 Bytes

Versions: 1

Compression:

Stored size: 932 Bytes

Contents

module RedisRing

  class Application

    attr_reader :shards, :configuration

    def initialize(configuration)
      @configuration = configuration
      @shards = {}
    end

    def start
      self.stop

      @configuration.ring_size.times do |shard_number|
        shard_conf = ShardConfig.new(shard_number, configuration)
        @shards[shard_number] = Shard.new(shard_conf)
      end

      @shards.each do |shard_no, shard|
        shard.start
      end
    end

    def stop
      @shards.each do |shard_no, shard|
        shard.stop
      end
      @shards = {}
    end

    def shards_hash
      shards_hash = {}
      shards.each do |shard_no, shard|
        shards_hash[shard_no] = { :host => shard.host, :port => shard.port, :status => shard.status }
      end

      return { :count => configuration.ring_size, :shards => shards_hash }
    end

    class << self
      attr_accessor :instance
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redis_ring-0.0.1 lib/redis_ring/application.rb