Method: Puppet::Transaction::EventManager#queue_events

Defined in:
lib/puppet/transaction/event_manager.rb

#queue_events(resource, events) ⇒ void

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.

This method returns an undefined value.

Queues events for other resources to respond to. All of these events have to be from the same resource.

Parameters:

  • The resource generating the given events

  • All events generated by this resource

API:

  • private



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/puppet/transaction/event_manager.rb', line 52

def queue_events(resource, events)
  # @events += events

  # Do some basic normalization so we're not doing so many
  # graph queries for large sets of events.
  events.each_with_object({}) do |event, collection|
    collection[event.name] ||= []
    collection[event.name] << event
  end.collect do |_name, list|
    # It doesn't matter which event we use - they all have the same source
    # and name here.
    event = list[0]

    # Collect the targets of any subscriptions to those events.  We pass
    # the parent resource in so it will override the source in the events,
    # since eval_generated children can't have direct relationships.
    received = (event.name != :restarted)
    relationship_graph.matching_edges(event, resource).each do |edge|
      received ||= true unless edge.target.is_a?(Puppet::Type.type(:whit))
      method = edge.callback
      next unless method
      next unless edge.target.respond_to?(method)

      queue_events_for_resource(resource, edge.target, method, list)
    end
    @events << event if received

    queue_events_for_resource(resource, resource, :refresh, [event]) if resource.self_refresh? and !resource.deleting?
  end

  dequeue_events_for_resource(resource, :refresh) if events.detect(&:invalidate_refreshes)
end