lib/arborist/command/watch.rb in arborist-0.1.0 vs lib/arborist/command/watch.rb in arborist-0.2.0.pre20170519125456
- old
+ new
@@ -3,10 +3,11 @@
require 'msgpack'
require 'arborist/cli' unless defined?( Arborist::CLI )
require 'arborist/client'
+require 'arborist/event_api'
# Command to watch events in an Arborist manager.
module Arborist::CLI::Watch
extend Arborist::CLI::Subcommand
@@ -28,15 +29,13 @@
begin
last_runid = nil
prompt.say "Watching for events on manager at %s" % [ client.event_api_url ]
loop do
- msgsubid = sock.recv
- raise "Partial write?!" unless sock.rcvmore?
- raw_event = sock.recv
- event = MessagePack.unpack( raw_event )
+ msg = sock.receive
+ subid, event = Arborist::EventAPI.decode( msg )
- case msgsubid
+ case subid
when 'sys.heartbeat'
this_runid = event['run_id']
if last_runid && last_runid != this_runid
self.log.warn "Manager restart: re-subscribing."