summaryrefslogtreecommitdiff
path: root/lib/chef/event_dispatch
diff options
context:
space:
mode:
authorAdam Jacob <adam@opscode.com>2015-01-22 22:17:24 -0800
committerThom May <thom@chef.io>2015-11-09 15:02:39 +0000
commitc03d49c7cc3b5eb351abc9f6537a1a65692e93fc (patch)
tree83c528f4fb89b1c26a45396bf4f0542c180d24de /lib/chef/event_dispatch
parentd70014cbcbb99558437587cf03f7b1ec3939df81 (diff)
downloadchef-c03d49c7cc3b5eb351abc9f6537a1a65692e93fc.tar.gz
Implement live streaming for execute resources
This brings live streaming of execute resource output to the output formatters. It also adds a mechanism for checking to see if an output formatter is in use through the event dispatch system. It adds a new configuration option, "always_stream_execute", which does what it says on the tin.
Diffstat (limited to 'lib/chef/event_dispatch')
-rw-r--r--lib/chef/event_dispatch/dispatcher.rb10
-rw-r--r--lib/chef/event_dispatch/events_output_stream.rb8
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/chef/event_dispatch/dispatcher.rb b/lib/chef/event_dispatch/dispatcher.rb
index f3e55539a9..affac8fb9d 100644
--- a/lib/chef/event_dispatch/dispatcher.rb
+++ b/lib/chef/event_dispatch/dispatcher.rb
@@ -20,6 +20,16 @@ class Chef
@subscribers << subscriber
end
+ # Check to see if we are dispatching to a formatter
+ def formatter?
+ @subscribers.each do |s|
+ if s.class <= Chef::Formatters::Base && s.class != Chef::Formatters::NullFormatter
+ return true
+ end
+ end
+ false
+ end
+
####
# All messages are unconditionally forwarded to all subscribers, so just
# define the forwarding in one go:
diff --git a/lib/chef/event_dispatch/events_output_stream.rb b/lib/chef/event_dispatch/events_output_stream.rb
index 8de9b0fed1..d9c21642b7 100644
--- a/lib/chef/event_dispatch/events_output_stream.rb
+++ b/lib/chef/event_dispatch/events_output_stream.rb
@@ -21,6 +21,14 @@ class Chef
events.stream_output(self, str, options)
end
+ def <<(str)
+ events.stream_output(self, str, options)
+ end
+
+ def write(str)
+ events.stream_output(self, str, options)
+ end
+
def close
events.stream_closed(self, options)
end