Class: Karafka::Instrumentation::Vendors::Kubernetes::SwarmLivenessListener

Inherits:
BaseListener
  • Object
show all
Defined in:
lib/karafka/instrumentation/vendors/kubernetes/swarm_liveness_listener.rb

Overview

Kubernetes HTTP listener designed to operate with Karafka running in the swarm mode In the Swarm mode we supervise only the supervisor as other nodes are suppose to be managed by the swarm supervisor

Instance Method Summary collapse

Constructor Details

#initialize(hostname: nil, port: 3000, controlling_ttl: 60 * 1_000) ⇒ SwarmLivenessListener

Returns a new instance of SwarmLivenessListener.

Parameters:

  • hostname (String, nil) (defaults to: nil)

    hostname or nil to bind on all

  • port (Integer) (defaults to: 3000)

    TCP port on which we want to run our HTTP status server

  • controlling_ttl (Integer) (defaults to: 60 * 1_000)

    time in ms after which we consider the supervising thread dead because it is not controlling nodes. When configuring this, please take into consideration, that during shutdown of the swarm, there is no controlling happening.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/karafka/instrumentation/vendors/kubernetes/swarm_liveness_listener.rb', line 19

def initialize(
  hostname: nil,
  port: 3000,
  controlling_ttl: 60 * 1_000
)
  @hostname = hostname
  @port = port
  @controlling_ttl = controlling_ttl
  @controlling = monotonic_now
  super(port: port, hostname: hostname)
end

Instance Method Details

#on_app_supervising(_event) ⇒ Object

Starts reporting in the supervisor only when it runs

Parameters:

  • _event (Karafka::Core::Monitoring::Event)


33
34
35
# File 'lib/karafka/instrumentation/vendors/kubernetes/swarm_liveness_listener.rb', line 33

def on_app_supervising(_event)
  start
end

#on_swarm_manager_control(_event) ⇒ Object

Tick on each control

Parameters:

  • _event (Karafka::Core::Monitoring::Event)


39
40
41
# File 'lib/karafka/instrumentation/vendors/kubernetes/swarm_liveness_listener.rb', line 39

def on_swarm_manager_control(_event)
  @controlling = monotonic_now
end