Module: Stockpile::RedisConnectionsFactory
- Defined in:
- lib/stockpile/redis_connections_factory.rb
Overview
Stockpile::RedisConnectionsFactory
Builds out connection pools out of provided configuration. Configurations are built with ‘*RedisConfiguration` classes. Providing a `.yml` file will override everything else and use that to build a config.
Class Method Summary collapse
Class Method Details
.build_connections ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/stockpile/redis_connections_factory.rb', line 26 def build_connections configuration.each do |database| pool = ConnectionPool.new(database[:pool_configuration]) do Redis.new(database[:redis_configuration]) end RedisConnections.instance_variable_set("@#{database[:db]}".to_sym, pool) RedisConnections.instance_variable_set("@#{database[:db]}_compression".to_sym, database[:compression]) end RedisConnections end |
.configuration ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/stockpile/redis_connections_factory.rb', line 39 def configuration if Stockpile.configuration.configuration_file Stockpile::YamlRedisConfiguration.configuration else Stockpile::DefaultRedisConfiguration.configuration end end |
.process_sentinels(sentinels:) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/stockpile/redis_connections_factory.rb', line 47 def process_sentinels(sentinels:) sentinels.split(',').map do |sentinel| host, port = sentinel.split(':') { host: host, port: port.to_i } end end |