Class: Karafka::Instrumentation::Vendors::Kubernetes::BaseListener

Inherits:
Object
  • Object
show all
Includes:
Core::Helpers::Time
Defined in:
lib/karafka_ext/k8s.rb

Overview

Base Kubernetes Listener providing basic HTTP server capabilities to respond with health

Direct Known Subclasses

LivenessListener

Instance Method Summary collapse

Constructor Details

#initialize(hostname: nil, port: 4000, logger: ActiveSupport::Logger.new(STDOUT)) ⇒ BaseListener

Returns a new instance of BaseListener.

Parameters:

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

    hostname or nil to bind on all

  • port (Integer) (defaults to: 4000)

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



22
23
24
25
26
27
28
29
30
# File 'lib/karafka_ext/k8s.rb', line 22

def initialize(
  hostname: nil,
  port: 4000,
  logger: ActiveSupport::Logger.new(STDOUT)
)
  @hostname = hostname
  @port = port
  @logger  = logger
end

Instance Method Details

#healthy?Boolean

Returns true if all good, false if we should tell k8s to kill this process.

Returns:

  • (Boolean)

    true if all good, false if we should tell k8s to kill this process

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/karafka_ext/k8s.rb', line 33

def healthy?
  raise NotImplementedError, 'Implement in a subclass'
end