examples/sandwich_worker.rb in cloudist-0.1.2 vs examples/sandwich_worker.rb in cloudist-0.2.0

- old
+ new

@@ -17,26 +17,20 @@ Cloudist.signal_trap! Cloudist.start { log.info("Started Worker") - worker { - job('make.sandwich') { - # Fire the started event + job('make.sandwich') { + log.info("JOB (#{id}) Make sandwich with #{data[:bread]} bread") + + job.started! + + (1..20).each do |i| + job.progress(i * 5) + sleep(1) - log.info("JOB (#{id}) Make sandwich with #{data[:bread]} bread") - log.debug(data.inspect) - - EM.defer { - progress(0) - started! - progress(10) - sleep(1) - progress(20) - sleep(5) - progress(90) - finished! - progress(100) - } - } + raise ArgumentError, "NOT GOOD!" if i == 4 + end + job.finished! } + }