Class: LanGrove::Root::Base
- Inherits:
-
Object
- Object
- LanGrove::Root::Base
- Defined in:
- lib/langrove/root/root_base.rb
Instance Attribute Summary collapse
-
#alerter ⇒ Object
Returns the value of attribute alerter.
-
#config ⇒ Object
Returns the value of attribute config.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#metrix ⇒ Object
Returns the value of attribute metrix.
Instance Method Summary collapse
-
#initialize(config, logger, config_instance = nil) ⇒ Base
constructor
A new instance of Base.
- #schedule(at, at_config, behaviour) ⇒ Object
- #trigger(recipient, recipient_type, event) ⇒ Object
Constructor Details
#initialize(config, logger, config_instance = nil) ⇒ Base
Returns a new instance of Base.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/langrove/root/root_base.rb', line 117 def initialize( config, logger, config_instance = nil ) @config = config_instance.nil? ? LanGrove::Config::Base.new( self, config, logger ) : config_instance @config.instance_variable_set( :@logger, logger ) # # Behaviours are configured to run at # key points in the Daemon life cycle. # # eg. # # call[:server][:stop] << [ behaviour, parameters ] # # will result in... # # behaviour.call( @server, parameters ) # # @call = { :server => { :start => [], :stop => [], :reload => [] }, :handler => { :start => [], :stop => [], :reload => [], :connect => [], :after_connect => [], :disconnect => [], :after_disconnect => [], :receive => [], :after_receive => [], :first_message => [], :error => [], # why no after error? :store => [], :after_store => [], :fetch => [], :after_fetch => [], :notify => [], # why no after notify? :enqueue => [], :after_enqueue => [], :request => [], :after_request => [] }, :multiplexer => { :start => [], :stop => [] } } @fingerprint = { :host_name => 'Later...', :serial => 'Absolute Uniqueness', :provisioned_at => 'Later...', :provisioned_by => 'Later...', :alert_queue => 'Later...' } @running_config = { :original_source => 'config.core.net', :update_interval => 'Later...', :code_version => 'Later...', :config_version => 'Later...', :local_daemons => { :local_daemon_name_1 => { :code_version => 'version', :config_version => 'version' }, :local_daemon_name_2 => { :code_version => 'version', :config_version => 'version' }, :local_daemon_name_3 => { :code_version => 'version', :config_version => 'version' } } } @logger = logger # # LAter... # @alerter = LanGrove::Alerter::Base.new @metrix = LanGrove::Metrix::Base.new( self ) end |
Instance Attribute Details
#alerter ⇒ Object
Returns the value of attribute alerter.
62 63 64 |
# File 'lib/langrove/root/root_base.rb', line 62 def alerter @alerter end |
#config ⇒ Object
Returns the value of attribute config.
65 66 67 |
# File 'lib/langrove/root/root_base.rb', line 65 def config @config end |
#logger ⇒ Object
Returns the value of attribute logger.
64 65 66 |
# File 'lib/langrove/root/root_base.rb', line 64 def logger @logger end |
#metrix ⇒ Object
Returns the value of attribute metrix.
63 64 65 |
# File 'lib/langrove/root/root_base.rb', line 63 def metrix @metrix end |
Instance Method Details
#schedule(at, at_config, behaviour) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/langrove/root/root_base.rb', line 87 def schedule( at, at_config, behaviour ) receiver, event = at.to_s.split( '_', 2 ) raise LanGrove::DaemonConfigException.new( "#{behaviour.class} cannot bind to non existant event #{at}" ) unless ( @call.has_key?( receiver.to_sym ) and @call[ receiver.to_sym ].has_key?( event.to_sym ) ) # # Multiple behaviours can be assiged to each event. # # At triggertime they will be called in the sequence # they were assigned. # @call[ receiver.to_sym ][ event.to_sym ] << [ behaviour, at_config ] end |
#trigger(recipient, recipient_type, event) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/langrove/root/root_base.rb', line 67 def trigger( recipient, recipient_type, event ) @logger.debug "TRIGGER #{recipient} #{recipient_type} #{event}" # # @metrix.notify( recipient, recipient_type, event ) # @call[ recipient_type ][ event ].each do | callback | behaviour = callback[0] parameter = callback[1] behaviour.call( recipient, recipient_type, parameter ) end end |