Class: RServiceBus2::Monitor
- Inherits:
-
Object
- Object
- RServiceBus2::Monitor
- Defined in:
- lib/rservicebus2/monitor.rb
Overview
Monitor
Direct Known Subclasses
MonitorAWSS3, MonitorAWSSQS, MonitorBeanstalk, MonitorDir, MonitorDirNotifier
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.
28 29 30 31 32 33 34 35 36 |
# File 'lib/rservicebus2/monitor.rb', line 28 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.
6 7 8 |
# File 'lib/rservicebus2/monitor.rb', line 6 def bus @bus end |
Instance Method Details
#_connect ⇒ Object
18 19 20 21 22 |
# File 'lib/rservicebus2/monitor.rb', line 18 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.
9 10 11 |
# File 'lib/rservicebus2/monitor.rb', line 9 def connect(_uri) raise 'Method, connect, needs to be implemented for resource' end |
#finished ⇒ Object
A notification that allows cleanup
39 40 41 |
# File 'lib/rservicebus2/monitor.rb', line 39 def finished RServiceBus2.rlog "#{self.class.name}. Default Finished" end |
#look ⇒ Object
The method which actually connects to the resource.
14 15 16 |
# File 'lib/rservicebus2/monitor.rb', line 14 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
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rservicebus2/monitor.rb', line 45 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
57 58 59 60 61 |
# File 'lib/rservicebus2/monitor.rb', line 57 def send(payload, uri) msg = @msg_type.new(payload, uri) @bus.send(msg) end |