diff options
author | Steve Kemp <steve@steve.org.uk> | 2015-12-18 15:59:03 +0200 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2015-12-18 15:59:03 +0200 |
commit | 2db7fba4d74b663da16625a990f7b7624842712a (patch) | |
tree | 0de4b3f3c3139cccfa36342a5e697b14a32f4e2d /queue/set/run.rb | |
parent | 43d6c5affc78755f8a45b242d8d39acc72bd3526 (diff) |
Added queue-demonstration programs.
Diffstat (limited to 'queue/set/run.rb')
-rwxr-xr-x | queue/set/run.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/queue/set/run.rb b/queue/set/run.rb new file mode 100755 index 0000000..f0b7476 --- /dev/null +++ b/queue/set/run.rb @@ -0,0 +1,32 @@ +#!/usr/bin/ruby + +require "redis" +require 'pp' +@redis = Redis.new(:host => "127.0.0.1") + + + +def fetch(timeout = 1) + job = nil + + loop do + job = @redis.spop('set') + + if !job.nil? + return job + else + sleep(timeout) + end + + end +end + + + +while( x = fetch() ) + puts "Got job : #{x}" + if ( x =~ /ping/i ) + puts "PING TEST - sleeping" + sleep 5 + end +end |