Class: NATS::Service::Status
- Inherits:
-
Object
- Object
- NATS::Service::Status
- Defined in:
- lib/nats/service/status.rb
Instance Attribute Summary collapse
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
Instance Method Summary collapse
- #basic ⇒ Object
- #info ⇒ Object
-
#initialize(service) ⇒ Status
constructor
A new instance of Status.
- #stats ⇒ Object
Constructor Details
#initialize(service) ⇒ Status
8 9 10 11 |
# File 'lib/nats/service/status.rb', line 8 def initialize(service) @service = service @started_at = Time.now end |
Instance Attribute Details
#service ⇒ Object (readonly)
Returns the value of attribute service.
6 7 8 |
# File 'lib/nats/service/status.rb', line 6 def service @service end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
6 7 8 |
# File 'lib/nats/service/status.rb', line 6 def started_at @started_at end |
Instance Method Details
#basic ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/nats/service/status.rb', line 13 def basic { name: service.name, id: service.id, version: service.version, metadata: service. } end |
#info ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/nats/service/status.rb', line 22 def info { **basic, description: service.description, endpoints: service.endpoints.map do |endpoint| { name: endpoint.name, subject: endpoint.subject, queue_group: endpoint.queue, metadata: endpoint. } end } end |
#stats ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/nats/service/status.rb', line 37 def stats { **basic, started: started_at.utc.iso8601, endpoints: service.endpoints.map do |endpoint| endpoint_stats(endpoint) end } end |