Module: Dry::System::Plugins::Monitoring

Defined in:
lib/dry/system/plugins/monitoring.rb,
lib/dry/system/plugins/monitoring/proxy.rb

Defined Under Namespace

Classes: Proxy

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dependenciesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


21
22
23
# File 'lib/dry/system/plugins/monitoring.rb', line 21

def self.dependencies
  'dry/events/publisher'
end

.extended(system) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


10
11
12
13
14
15
16
17
18
# File 'lib/dry/system/plugins/monitoring.rb', line 10

def self.extended(system)
  super

  system.use(:notifications)

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

Instance Method Details

#monitor(key, options = EMPTY_HASH, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/dry/system/plugins/monitoring.rb', line 26

def monitor(key, options = EMPTY_HASH, &block)
  notifications = self[:notifications]

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

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

    decorate(key, with: proxy.new(target, notifications))
  end
end