Class: NATS::Service
- Inherits:
-
Object
- Object
- NATS::Service
- Includes:
- MonitorMixin
- Defined in:
- lib/nats/service.rb,
lib/nats/service/group.rb,
lib/nats/service/stats.rb,
lib/nats/service/errors.rb,
lib/nats/service/status.rb,
lib/nats/service/endpoint.rb,
lib/nats/service/callbacks.rb,
lib/nats/service/validator.rb,
lib/nats/service/monitoring.rb
Defined Under Namespace
Modules: Validator Classes: Callbacks, Endpoint, Endpoints, Error, ErrorWrapper, Group, Groups, InvalidNameError, InvalidQueueError, InvalidSubjectError, InvalidVersionError, Monitoring, Request, Stats, Status
Constant Summary collapse
- DEFAULT_QUEUE =
"q"
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
readonly
Returns the value of attribute callbacks.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#endpoints ⇒ Object
readonly
Returns the value of attribute endpoints.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#monitoring ⇒ Object
readonly
Returns the value of attribute monitoring.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(client, options) ⇒ Service
constructor
A new instance of Service.
- #on_stats(&block) ⇒ Object
- #on_stop(&block) ⇒ Object
- #reset ⇒ Object
- #service ⇒ Object
- #stats ⇒ Object
- #stop(error = nil) ⇒ Object
- #stopped? ⇒ Boolean
- #subject ⇒ Object
Constructor Details
#initialize(client, options) ⇒ Service
24 25 26 27 28 29 30 |
# File 'lib/nats/service.rb', line 24 def initialize(client, ) super() validate() () setup_internals(client) end |
Instance Attribute Details
#callbacks ⇒ Object (readonly)
Returns the value of attribute callbacks.
22 23 24 |
# File 'lib/nats/service.rb', line 22 def callbacks @callbacks end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
21 22 23 |
# File 'lib/nats/service.rb', line 21 def client @client end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
21 22 23 |
# File 'lib/nats/service.rb', line 21 def description @description end |
#endpoints ⇒ Object (readonly)
Returns the value of attribute endpoints.
22 23 24 |
# File 'lib/nats/service.rb', line 22 def endpoints @endpoints end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
22 23 24 |
# File 'lib/nats/service.rb', line 22 def groups @groups end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
21 22 23 |
# File 'lib/nats/service.rb', line 21 def id @id end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
21 22 23 |
# File 'lib/nats/service.rb', line 21 def end |
#monitoring ⇒ Object (readonly)
Returns the value of attribute monitoring.
22 23 24 |
# File 'lib/nats/service.rb', line 22 def monitoring @monitoring end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/nats/service.rb', line 21 def name @name end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
21 22 23 |
# File 'lib/nats/service.rb', line 21 def queue @queue end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
22 23 24 |
# File 'lib/nats/service.rb', line 22 def status @status end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
21 22 23 |
# File 'lib/nats/service.rb', line 21 def version @version end |
Instance Method Details
#info ⇒ Object
61 62 63 |
# File 'lib/nats/service.rb', line 61 def info status.info end |
#on_stats(&block) ⇒ Object
32 33 34 |
# File 'lib/nats/service.rb', line 32 def on_stats(&block) callbacks.register(:stats, &block) end |
#on_stop(&block) ⇒ Object
36 37 38 |
# File 'lib/nats/service.rb', line 36 def on_stop(&block) callbacks.register(:stop, &block) end |
#reset ⇒ Object
57 58 59 |
# File 'lib/nats/service.rb', line 57 def reset endpoints.each(&:reset) end |
#service ⇒ Object
69 70 71 |
# File 'lib/nats/service.rb', line 69 def service self end |
#stats ⇒ Object
65 66 67 |
# File 'lib/nats/service.rb', line 65 def stats status.stats end |
#stop(error = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/nats/service.rb', line 44 def stop(error = nil) return if stopped? synchronize do monitoring&.stop endpoints&.each(&:stop) callbacks&.call(:stop, error) end ensure synchronize { @stopped = true } end |
#stopped? ⇒ Boolean
40 41 42 |
# File 'lib/nats/service.rb', line 40 def stopped? !!@stopped end |
#subject ⇒ Object
73 74 75 |
# File 'lib/nats/service.rb', line 73 def subject nil end |