Class: NATS::Service::Monitoring
- Inherits:
-
Object
- Object
- NATS::Service::Monitoring
- Defined in:
- lib/nats/service/monitoring.rb
Constant Summary collapse
- DEFAULT_PREFIX =
"$SRV"
- VERBS =
{ ping: "PING", info: "INFO", stats: "STATS" }.freeze
- TYPES =
{ ping: "io.nats.micro.v1.ping_response", info: "io.nats.micro.v1.info_response", stats: "io.nats.micro.v1.stats_response" }.freeze
Instance Attribute Summary collapse
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#stopped ⇒ Object
readonly
Returns the value of attribute stopped.
Instance Method Summary collapse
-
#initialize(service, prefix = nil) ⇒ Monitoring
constructor
A new instance of Monitoring.
- #stop ⇒ Object
- #stopped? ⇒ Boolean
Constructor Details
#initialize(service, prefix = nil) ⇒ Monitoring
Returns a new instance of Monitoring.
24 25 26 27 28 29 |
# File 'lib/nats/service/monitoring.rb', line 24 def initialize(service, prefix = nil) @service = service @prefix = prefix || DEFAULT_PREFIX setup_monitors end |
Instance Attribute Details
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
22 23 24 |
# File 'lib/nats/service/monitoring.rb', line 22 def prefix @prefix end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
22 23 24 |
# File 'lib/nats/service/monitoring.rb', line 22 def service @service end |
#stopped ⇒ Object (readonly)
Returns the value of attribute stopped.
22 23 24 |
# File 'lib/nats/service/monitoring.rb', line 22 def stopped @stopped end |
Instance Method Details
#stop ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nats/service/monitoring.rb', line 31 def stop return if @monitors.nil? @monitors.each do |monitor| service.client.send(:drain_sub, monitor) end rescue # nothing we can do here ensure @monitors = nil end |
#stopped? ⇒ Boolean
43 44 45 |
# File 'lib/nats/service/monitoring.rb', line 43 def stopped? @monitors.nil? end |