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.



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

def self.dependencies
  {"dry-events": "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.



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

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, &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.



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

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: -> tgt { proxy.new(tgt, notifications) })
  end
end