Class: Raidis::Configuration
- Inherits:
-
Object
- Object
- Raidis::Configuration
- Defined in:
- lib/raidis/configuration.rb
Defined Under Namespace
Classes: Master
Constant Summary collapse
- InfoFilePathNotFound =
Class.new(RuntimeError)
Instance Attribute Summary collapse
- #logger ⇒ Object
- #master ⇒ Object
-
#redis_db ⇒ Object
Returns the value of attribute redis_db.
-
#redis_namespace ⇒ Object
Returns the value of attribute redis_namespace.
-
#redis_timeout ⇒ Object
Returns the value of attribute redis_timeout.
- #retries ⇒ Object
- #retry_interval ⇒ Object
- #unavailability_timeout ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#logger ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/raidis/configuration.rb', line 18 def logger @logger ||= begin if defined?(Rails) Rails.logger else Logger.new(STDOUT) end end end |
#master ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/raidis/configuration.rb', line 48 def master unless @master unless info_file_path.exist? Trouble.notify(InfoFilePathNotFound.new, code: :info_file_not_found, message: 'Raidis could not find the redis master info file', location: info_file_path) if defined?(Trouble) return end unless info_file_path.readable? Trouble.notify(InfoFilePathNotFound.new, code: :info_file_not_readable, message: 'The redis master info file exists but is not readable for Raidis', location: info_file_path) if defined?(Trouble) return end end content = @master || info_file_path.read server = Master.new server.endpoint, server.port = content.strip.to_s.split(':') unless server.endpoint if @master Trouble.notify(InfoFilePathNotFound.new, code: :invalid_master, message: 'Raidis does not understand the config.master value you provided', value: config.master.inspect) if defined?(Trouble) else Trouble.notify(InfoFilePathNotFound.new, code: :invalid_info_file_content, message: 'Raidis found the redis master info file, but there was no valid endpoint in it', location: info_file_path, content: info_file_path.read.inspect) if defined?(Trouble) end return end server end |
#redis_db ⇒ Object
Returns the value of attribute redis_db.
15 16 17 |
# File 'lib/raidis/configuration.rb', line 15 def redis_db @redis_db end |
#redis_namespace ⇒ Object
Returns the value of attribute redis_namespace.
15 16 17 |
# File 'lib/raidis/configuration.rb', line 15 def redis_namespace @redis_namespace end |
#redis_timeout ⇒ Object
Returns the value of attribute redis_timeout.
15 16 17 |
# File 'lib/raidis/configuration.rb', line 15 def redis_timeout @redis_timeout end |
#retries ⇒ Object
40 41 42 |
# File 'lib/raidis/configuration.rb', line 40 def retries @retries ||= 1 end |
#retry_interval ⇒ Object
44 45 46 |
# File 'lib/raidis/configuration.rb', line 44 def retry_interval @retry_interval ||= 3 end |
#unavailability_timeout ⇒ Object
36 37 38 |
# File 'lib/raidis/configuration.rb', line 36 def unavailability_timeout @unavailability_timeout ||= 15 # seconds end |
Instance Method Details
#info_file_path ⇒ Object
28 29 30 |
# File 'lib/raidis/configuration.rb', line 28 def info_file_path @info_file_path ||= Pathname.new('/etc/redis_master') end |
#info_file_path=(path) ⇒ Object
32 33 34 |
# File 'lib/raidis/configuration.rb', line 32 def info_file_path=(path) Pathname.new path end |