Class: RServiceBus::Monitor
- Inherits:
-
Object
- Object
- RServiceBus::Monitor
- Defined in:
- lib/rservicebus/Monitor.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#Bus ⇒ Object
Returns the value of attribute Bus.
Instance Method Summary collapse
- #_connect ⇒ Object
-
#connect(uri) ⇒ Object
The method which actually connects to the resource.
-
#finished ⇒ Object
A notification that allows cleanup.
-
#initialize(bus, name, uri) ⇒ Monitor
constructor
Resources are attached resources, and can be specified using the URI syntax.
-
#Look ⇒ Object
The method which actually connects to the resource.
-
#reconnect ⇒ Object
At least called in the Host rescue block, to ensure all network links are healthy.
- #send(payload, uri) ⇒ Object
Constructor Details
#initialize(bus, name, uri) ⇒ Monitor
Resources are attached resources, and can be specified using the URI syntax.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rservicebus/Monitor.rb', line 32 def initialize( bus, name, uri ) @Bus = bus # @MsgType = Object.const_get( name ) newAnonymousClass = Class.new(Monitor_Message) Object.const_set( name, newAnonymousClass ) @MsgType = Object.const_get( name ) @uri = uri self._connect end |
Instance Attribute Details
#Bus ⇒ Object
Returns the value of attribute Bus.
5 6 7 |
# File 'lib/rservicebus/Monitor.rb', line 5 def Bus @Bus end |
Instance Method Details
#_connect ⇒ Object
24 25 26 27 |
# File 'lib/rservicebus/Monitor.rb', line 24 def _connect @connection = self.connect(@uri) @Bus.log "#{self.class.name}. Connected to, #{@uri.to_s}" if ENV['QUIET'].nil? end |
#connect(uri) ⇒ Object
The method which actually connects to the resource.
14 15 16 |
# File 'lib/rservicebus/Monitor.rb', line 14 def connect(uri) raise 'Method, connect, needs to be implemented for resource' end |
#finished ⇒ Object
A notification that allows cleanup
44 45 |
# File 'lib/rservicebus/Monitor.rb', line 44 def finished end |
#Look ⇒ Object
The method which actually connects to the resource.
20 21 22 |
# File 'lib/rservicebus/Monitor.rb', line 20 def Look raise 'Method, Look, needs to be implemented for the Monitor' end |
#reconnect ⇒ Object
At least called in the Host rescue block, to ensure all network links are healthy
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rservicebus/Monitor.rb', line 48 def reconnect begin self.finished rescue Exception => e puts '** Monitor. An error was raised while closing connection to, ' + @uri.to_s puts 'Message: ' + e. puts e.backtrace end self._connect end |
#send(payload, uri) ⇒ Object
60 61 62 63 64 |
# File 'lib/rservicebus/Monitor.rb', line 60 def send( payload, uri ) msg = @MsgType.new( payload, uri ) @Bus.Send( msg ) end |