Sha256: d84db17487bc8634e5329ae64ad591d41ca69c8f8a7f69505736be35eddc8dc4

Contents?: true

Size: 539 Bytes

Versions: 1

Compression:

Stored size: 539 Bytes

Contents

# frozen_string_literal: true

class Async::App::WebApps::MetricsApp
  include Async::App::WebComponent
  include Async::App::AutoloadComponent

  PATHS = ["/metrics", "/metrics/"].freeze

  inject :async_app_name

  def after_init
    store = Store.new
    @serializer = Serializer.new(prefix: async_app_name, store:)

    bus.subscribe("metrics.updated") do |metrics|
      metrics.each { store.set(_1, **_2) }
    end
  end

  def can_handle?(request) = PATHS.include?(request.path)
  def call(*) = [200, {}, @serializer.serialize]
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
async-tools-0.2.10 lib/async/app/web_apps/metrics_app.rb