Class: ProxyMgr::Watcher::Base
- Inherits:
-
Object
- Object
- ProxyMgr::Watcher::Base
- Includes:
- Logging
- Defined in:
- lib/proxymgr/watcher/base.rb
Instance Attribute Summary collapse
-
#listen_options ⇒ Object
readonly
Returns the value of attribute listen_options.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server_options ⇒ Object
readonly
Returns the value of attribute server_options.
-
#servers ⇒ Object
readonly
Returns the value of attribute servers.
Instance Method Summary collapse
- #==(obj) ⇒ Object
-
#initialize(name, config, manager) ⇒ Base
constructor
A new instance of Base.
- #shutdown ⇒ Object
- #valid? ⇒ Boolean
- #watch ⇒ Object
Methods included from Logging
Constructor Details
#initialize(name, config, manager) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/proxymgr/watcher/base.rb', line 8 def initialize(name, config, manager) @name = name @manager = manager @config = config @servers = [] @listen_options = @config['listen_options'] @server_options = @config['server_options'] @port = @config['port'] end |
Instance Attribute Details
#listen_options ⇒ Object (readonly)
Returns the value of attribute listen_options.
4 5 6 |
# File 'lib/proxymgr/watcher/base.rb', line 4 def @listen_options end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
4 5 6 |
# File 'lib/proxymgr/watcher/base.rb', line 4 def port @port end |
#server_options ⇒ Object (readonly)
Returns the value of attribute server_options.
4 5 6 |
# File 'lib/proxymgr/watcher/base.rb', line 4 def @server_options end |
#servers ⇒ Object (readonly)
Returns the value of attribute servers.
4 5 6 |
# File 'lib/proxymgr/watcher/base.rb', line 4 def servers @servers end |
Instance Method Details
#==(obj) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/proxymgr/watcher/base.rb', line 25 def ==(obj) if obj.is_a? Watcher::Base obj. == @listen_options and obj. == @server_options and obj.port == @port else super end end |
#shutdown ⇒ Object
23 |
# File 'lib/proxymgr/watcher/base.rb', line 23 def shutdown; end |
#valid? ⇒ Boolean
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/proxymgr/watcher/base.rb', line 35 def valid? unless @port warn 'port is not defined' return false end unless @port.is_a? Integer and (@port > 0 and @port <= 65535) warn 'port is not an integer or not valid' return false end unless !@listen_options || @listen_options.is_a?(Array) warn 'listen_options is not an array' return false end unless !@server_options || @server_options.is_a?(Array) warn 'server_options is not an array' return false end if has_validation? and !validate_config warn 'config failed to validate' return false end true end |
#watch ⇒ Object
19 20 21 |
# File 'lib/proxymgr/watcher/base.rb', line 19 def watch fail Exception 'This method should be overridden' end |