Sha256: 5653ddd03a9d300f43234c8a66b66c80fa3a99855407f605f3409e336f699d30

Contents?: true

Size: 799 Bytes

Versions: 12

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

module Sbmt
  module KafkaConsumer
    module Probes
      module Probe
        HEADERS = {"Content-Type" => "application/json"}.freeze

        def call(env)
          with_error_handler { probe(env) }
        end

        def meta
          {}
        end

        def probe_ok(extra_meta = {})
          [200, HEADERS, [meta.merge(extra_meta).to_json]]
        end

        def probe_error(extra_meta = {})
          KafkaConsumer.logger.error("probe error meta: #{meta.merge(extra_meta).inspect}")
          [500, HEADERS, [meta.merge(extra_meta).to_json]]
        end

        def with_error_handler
          yield
        rescue => error
          probe_error(error_class: error.class.name, error_message: error.message)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sbmt-kafka_consumer-3.3.0 lib/sbmt/kafka_consumer/probes/probe.rb
sbmt-kafka_consumer-3.2.2 lib/sbmt/kafka_consumer/probes/probe.rb
sbmt-kafka_consumer-3.2.1 lib/sbmt/kafka_consumer/probes/probe.rb
sbmt-kafka_consumer-3.2.0 lib/sbmt/kafka_consumer/probes/probe.rb
sbmt-kafka_consumer-3.1.0 lib/sbmt/kafka_consumer/probes/probe.rb
sbmt-kafka_consumer-2.8.0 lib/sbmt/kafka_consumer/probes/probe.rb
sbmt-kafka_consumer-3.0.0 lib/sbmt/kafka_consumer/probes/probe.rb
sbmt-kafka_consumer-2.7.1 lib/sbmt/kafka_consumer/probes/probe.rb
sbmt-kafka_consumer-2.7.0 lib/sbmt/kafka_consumer/probes/probe.rb
sbmt-kafka_consumer-2.6.1 lib/sbmt/kafka_consumer/probes/probe.rb
sbmt-kafka_consumer-2.6.0 lib/sbmt/kafka_consumer/probes/probe.rb
sbmt-kafka_consumer-2.5.0 lib/sbmt/kafka_consumer/probes/probe.rb