module Dry::System::Plugins::Monitoring

@api public

Public Class Methods

dependencies() click to toggle source

@api private

# File lib/dry/system/plugins/monitoring.rb, line 23
def self.dependencies
  {'dry-events': "dry/events/publisher"}
end
extended(system) click to toggle source

@api private

Calls superclass method
# File lib/dry/system/plugins/monitoring.rb, line 12
def self.extended(system)
  super

  system.use(:notifications)

  system.after(:configure) do
    self[:notifications].register_event(:monitoring)
  end
end

Public Instance Methods

monitor(key, **options, &block) click to toggle source

@api private

# File lib/dry/system/plugins/monitoring.rb, line 28
def monitor(key, **options, &block)
  notifications = self[:notifications]

  resolve(key).tap do |target|
    proxy = Proxy.for(target, **options, key: key)

    if block
      proxy.monitored_methods.each do |meth|
        notifications.subscribe(:monitoring, target: key, method: meth, &block)
      end
    end

    decorate(key, with: -> target { proxy.new(target, notifications) })
  end
end