Sha256: 8ce344d449f970eb85ec29ee3924ef5c3009764fe93e62c937a5f2ba5b1c04cf

Contents?: true

Size: 701 Bytes

Versions: 21

Compression:

Stored size: 701 Bytes

Contents

# frozen_string_literal: true

module Sbmt
  module KafkaConsumer
    module Instrumentation
      class ReadinessListener
        include ListenerHelper
        include KafkaConsumer::Probes::Probe

        def initialize
          setup_subscription
        end

        def on_app_running(_event)
          @ready = true
        end

        def on_app_stopping(_event)
          @ready = false
        end

        def probe(_env)
          ready? ? probe_ok(ready: true) : probe_error(ready: false)
        end

        private

        def ready?
          @ready
        end

        def setup_subscription
          Karafka::App.monitor.subscribe(self)
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
sbmt-kafka_consumer-3.3.2 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-3.3.1 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-3.3.0 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-3.2.2 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-3.2.1 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-3.2.0 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-3.1.0 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-2.8.0 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-3.0.0 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-2.7.1 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-2.7.0 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-2.6.1 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-2.6.0 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-2.5.0 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-2.4.1 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-2.4.0 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-2.3.1 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-2.3.0 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-2.2.0 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb
sbmt-kafka_consumer-2.1.0 lib/sbmt/kafka_consumer/instrumentation/readiness_listener.rb