Class: RServiceBus2::Monitor
- Inherits:
-
Object
- Object
- RServiceBus2::Monitor
- Defined in:
- lib/rservicebus2/monitor.rb
Overview
Monitor
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.
26 27 28 29 30 31 32 33 34 |
# File 'lib/rservicebus2/monitor.rb', line 26 def initialize(bus, name, uri) @bus = bus new_anonymous_class = Class.new(MonitorMessage) Object.const_set(name, new_anonymous_class) @msg_type = Object.const_get(name) @uri = uri _connect end |
Instance Attribute Details
#bus ⇒ Object
Returns the value of attribute bus.
4 5 6 |
# File 'lib/rservicebus2/monitor.rb', line 4 def bus @bus end |
Instance Method Details
#_connect ⇒ Object
16 17 18 19 20 |
# File 'lib/rservicebus2/monitor.rb', line 16 def _connect @connection = connect(@uri) @bus.log "#{self.class.name}. Connected to, #{@uri}" if ENV['QUIET'].nil? end |
#connect(_uri) ⇒ Object
The method which actually connects to the resource.
7 8 9 |
# File 'lib/rservicebus2/monitor.rb', line 7 def connect(_uri) fail 'Method, connect, needs to be implemented for resource' end |
#finished ⇒ Object
A notification that allows cleanup
37 38 |
# File 'lib/rservicebus2/monitor.rb', line 37 def finished end |
#look ⇒ Object
The method which actually connects to the resource.
12 13 14 |
# File 'lib/rservicebus2/monitor.rb', line 12 def look fail '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
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rservicebus2/monitor.rb', line 42 def reconnect begin finished rescue StandardError => e puts '** Monitor. An error was raised while closing connection to, ' + @uri puts 'Message: ' + e. puts e.backtrace end _connect end |
#send(payload, uri) ⇒ Object
55 56 57 58 59 |
# File 'lib/rservicebus2/monitor.rb', line 55 def send(payload, uri) msg = @msg_type.new(payload, uri) @bus.send(msg) end |