Sha256: 662298c29d4f705d2e40b80603edf3e3c8cf164627a07fdafa006099903c04f4

Contents?: true

Size: 950 Bytes

Versions: 3

Compression:

Stored size: 950 Bytes

Contents

# Cloudst Example: Sandwich Worker
# 
# This example demonstrates receiving a job and sending back events to the client to let it know we've started and finsihed
# making a sandwich. From here you could dispatch an eat.sandwich event.
# 
# Be sure to update the Cloudist connection settings if they differ from defaults:
# user: guest
# pass: guest
# port: 5672
# host: localhost
# vhost: /
# 
$:.unshift File.dirname(__FILE__) + '/../lib'
require "rubygems"
require "cloudist"

Cloudist.signal_trap!

Cloudist.start {
  log.info("Started Worker")
  
  worker {
    job('make.sandwich') {
      # Fire the started event
      
      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)
      }
    }    
  }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cloudist-0.1.2 examples/sandwich_worker.rb
cloudist-0.1.1 examples/sandwich_worker.rb
cloudist-0.1.0 examples/sandwich_worker.rb