Class: Async::App::WebApps::MetricsApp

Inherits:
Object
  • Object
show all
Includes:
AutoloadComponent, Async::App::WebComponent
Defined in:
lib/async/app/web_apps/metrics_app.rb

Constant Summary collapse

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

Instance Method Summary collapse

Methods included from AutoloadComponent

included

Methods included from Async::App::WebComponent

included

Instance Method Details

#after_initObject



11
12
13
14
15
16
17
18
# File 'lib/async/app/web_apps/metrics_app.rb', line 11

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

#callObject



21
# File 'lib/async/app/web_apps/metrics_app.rb', line 21

def call(*) = [200, {}, @serializer.serialize]

#can_handle?(request) ⇒ Boolean

Returns:

  • (Boolean)


20
# File 'lib/async/app/web_apps/metrics_app.rb', line 20

def can_handle?(request) = PATHS.include?(request.path)