Sha256: a50a51ef415f74a84dbd4748728493b2d31ff0f4062c1bfac089082fc21908ef

Contents?: true

Size: 498 Bytes

Versions: 1

Compression:

Stored size: 498 Bytes

Contents

require 'aggro/version'

require 'consistent_hashing'

require 'aggro/aggregate_ref'

# Public: Module for namespacing and configuration methods.
module Aggro
  def self.initialize_hash_ring(servers = servers_from_env)
    ConsistentHashing::Ring.new.tap do |ring|
      servers.each { |server| ring.add server }
    end
  end

  def self.hash_ring
    @hash_ring ||= initialize_hash_ring
  end

  def self.servers_from_env
    ENV['AGGRO_SERVERS'] ? ENV['AGGRO_SERVERS'].split(',') : []
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aggro-0.0.1 lib/aggro.rb