Class: Artery::WorkerHealthzSubscription

Inherits:
Object
  • Object
show all
Defined in:
lib/artery/worker_healthz_subscription.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name) ⇒ WorkerHealthzSubscription

Returns a new instance of WorkerHealthzSubscription.



7
8
9
10
# File 'lib/artery/worker_healthz_subscription.rb', line 7

def initialize(id, name)
  @id = id
  @name = name
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/artery/worker_healthz_subscription.rb', line 5

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/artery/worker_healthz_subscription.rb', line 5

def name
  @name
end

Instance Method Details

#subscribeObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/artery/worker_healthz_subscription.rb', line 12

def subscribe
  healthz_route = "#{Artery.service_name}.healthz.#{name}"
  Artery.logger.debug "Subscribing on '#{healthz_route}' for #{name} #{id}"

  Artery.subscribe healthz_route do |data, reply, _from|
    next unless data['id'] == id

    Artery.publish reply, status: :ok
  end
end