summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-04-21 18:50:54 +0000
committerLuke Kanies <luke@madstop.com>2005-04-21 18:50:54 +0000
commitd0c6b0c23516fda12dd1a3d2f5a8e53b614100f0 (patch)
tree0a93a185682e4fd8e32395c0de0ac28fdb32fc27
parent89d23818abca673b0b7b29f0792afb8ec990ebb4 (diff)
downloadpuppet-d0c6b0c23516fda12dd1a3d2f5a8e53b614100f0.tar.gz
puppet-d0c6b0c23516fda12dd1a3d2f5a8e53b614100f0.tar.xz
puppet-d0c6b0c23516fda12dd1a3d2f5a8e53b614100f0.zip
adding transactions
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@205 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/blink/client.rb3
-rw-r--r--lib/blink/transaction.rb53
2 files changed, 56 insertions, 0 deletions
diff --git a/lib/blink/client.rb b/lib/blink/client.rb
index 9dd959b9f..207cd734b 100644
--- a/lib/blink/client.rb
+++ b/lib/blink/client.rb
@@ -51,6 +51,9 @@ module Blink
objects.each { |obj|
obj.evaluate
}
+
+ transaction = Blink::Transaction.new(objects)
+ transaction.run
end
end
end
diff --git a/lib/blink/transaction.rb b/lib/blink/transaction.rb
new file mode 100644
index 000000000..44733b187
--- /dev/null
+++ b/lib/blink/transaction.rb
@@ -0,0 +1,53 @@
+#!/usr/local/bin/ruby -w
+
+# $Id$
+
+# the class that actually walks our object/state tree, collects the changes,
+# and performs them
+
+# there are two directions of walking:
+# - first we recurse down the tree and collect changes
+# - then we walk back up the tree through 'refresh' after the changes
+
+require 'blink'
+require 'blink/statechange'
+
+#---------------------------------------------------------------
+class Blink::Transaction
+ attr_accessor :collect # do we collect the changes and perform them
+ # all at once?
+
+ #---------------------------------------------------------------
+ # for now, just store the changes for executing linearly
+ # later, we might execute them as we receive them
+ def change(change)
+ @changes.push change
+ end
+ #---------------------------------------------------------------
+
+ #---------------------------------------------------------------
+ def evaluate
+ @changes.each { |change|
+ next if change.noop
+
+ msg = change.sync
+ }
+ end
+ #---------------------------------------------------------------
+
+ #---------------------------------------------------------------
+ def initialize(tree)
+ @tree = tree
+ @collect = true
+ @changes = []
+ end
+ #---------------------------------------------------------------
+
+ #---------------------------------------------------------------
+ def run
+ tree.evaluate(self)
+ self.evaluate
+ end
+ #---------------------------------------------------------------
+end
+#---------------------------------------------------------------