From 429517d3f3ebe6094540ba698ba1e459cbfb7771 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Mon, 17 Sep 2007 13:26:01 -0700 Subject: [PATCH] update history and manifest --- History.txt | 2 ++ Manifest.txt | 2 ++ lib/god.rb | 33 ++++++++++++++++++--------------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/History.txt b/History.txt index b29bc87..5d191b5 100644 --- a/History.txt +++ b/History.txt @@ -4,9 +4,11 @@ * Implement lifecycle scoped metric to allow for cross-state conditions * Add TriggerCondition for conditions that need info about state changes * Implement notification system + * Add Tasks (a generalization of Watches) to do non-process related tasks * Minor Enchancements * Allow EventConditions to do transition overloading * Report errors during god startup instead of failing silently + * Make transition block optional (default to Always condition returning true) * New Conditions * Flapping < TriggerCondition - trigger on state change * New Contacts diff --git a/Manifest.txt b/Manifest.txt index 965896d..8500c12 100644 --- a/Manifest.txt +++ b/Manifest.txt @@ -40,6 +40,7 @@ lib/god/reporter.rb lib/god/server.rb lib/god/sugar.rb lib/god/system/process.rb +lib/god/task.rb lib/god/timeline.rb lib/god/timer.rb lib/god/trigger.rb @@ -60,6 +61,7 @@ test/configs/real.rb test/configs/running_load/running_load.god test/configs/stress/simple_server.rb test/configs/stress/stress.god +test/configs/task/task.god test/configs/test.rb test/helper.rb test/suite.rb diff --git a/lib/god.rb b/lib/god.rb index a0189be..498439c 100644 --- a/lib/god.rb +++ b/lib/god.rb @@ -139,49 +139,52 @@ module God self.task(Watch, &block) end + # Instantiate a new, empty Task object and pass it to the mandatory + # block. The attributes of the task will be set by the configuration + # file. def self.task(klass = Task) self.internal_init - w = klass.new - yield(w) + t = klass.new + yield(t) # do the post-configuration - w.prepare + t.prepare # if running, completely remove the watch (if necessary) to # prepare for the reload - existing_watch = self.watches[w.name] + existing_watch = self.watches[t.name] if self.running && existing_watch self.unwatch(existing_watch) end # ensure the new watch has a unique name - if self.watches[w.name] || self.groups[w.name] - abort "Watch name '#{w.name}' already used for a Watch or Group" + if self.watches[t.name] || self.groups[t.name] + abort "Task name '#{t.name}' already used for a Task or Group" end # ensure watch is internally valid - w.valid? || abort("Watch '#{w.name}' is not valid (see above)") + t.valid? || abort("Task '#{t.name}' is not valid (see above)") # add to list of watches - self.watches[w.name] = w + self.watches[t.name] = t # add to pending watches - self.pending_watches << w + self.pending_watches << t # add to group if specified - if w.group + if t.group # ensure group name hasn't been used for a watch already - if self.watches[w.group] - abort "Group name '#{w.group}' already used for a Watch" + if self.watches[t.group] + abort "Group name '#{t.group}' already used for a Task" end - self.groups[w.group] ||= [] - self.groups[w.group] << w + self.groups[t.group] ||= [] + self.groups[t.group] << t end # register watch - w.register! + t.register! end def self.unwatch(watch) -- 2.11.4.GIT