diff options
| author | Luke Kanies <luke@madstop.com> | 2005-05-30 02:29:23 +0000 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2005-05-30 02:29:23 +0000 |
| commit | 0ab9685383bc21d9903a06d62a01f6cb72d25610 (patch) | |
| tree | ad8d5dac1e252b2e5a056d5665a751f9737108e3 /lib | |
| parent | 2b97b479688e987a8d9e663fd926108e7c02e7e4 (diff) | |
dependencies now work, although you cannot yet specify them for components
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@283 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/blink/event.rb | 16 | ||||
| -rw-r--r-- | lib/blink/transaction.rb | 8 |
2 files changed, 17 insertions, 7 deletions
diff --git a/lib/blink/event.rb b/lib/blink/event.rb index 1f3f21f72..99b922930 100644 --- a/lib/blink/event.rb +++ b/lib/blink/event.rb @@ -31,12 +31,15 @@ module Blink # the transaction is passed in so that we can notify it if # something fails def trigger(transaction) - # we need some mechanism for only triggering a subscription - # once per transaction, but, um, we don't want it to only - # be once per process lifetime - # so, for now, just trigger as many times as we can, rather than - # as few... - unless @triggered + # this is potentially incomplete, because refreshing an object + # could theoretically kick off an event, which would not get run + # or, because we're executing the first subscription rather than + # the last, a later-refreshed object could somehow be connected + # to the "old" object rather than "new" + # but we're pretty far from that being a problem + if transaction.triggered(self) > 1 + Blink.verbose "%s has already run" % self + else Blink.verbose "'%s' generated '%s'; triggering '%s' on '%s'" % [@source,@event,@method,@target] begin @@ -56,7 +59,6 @@ module Blink #raise "We need to roll '%s' transaction back" % #transaction end - #@triggered = true end end end diff --git a/lib/blink/transaction.rb b/lib/blink/transaction.rb index f5252b436..7bf0c8557 100644 --- a/lib/blink/transaction.rb +++ b/lib/blink/transaction.rb @@ -87,6 +87,8 @@ class Transaction @tree = tree @toplevel = false + @triggered = Hash.new(0) + # of course, this won't work on the second run unless defined? @@failures @toplevel = true @@ -132,6 +134,12 @@ class Transaction } end #--------------------------------------------------------------- + + #--------------------------------------------------------------- + def triggered(sub) + @triggered[sub] += 1 + end + #--------------------------------------------------------------- end end #--------------------------------------------------------------- |
