File: simple-usage

package info (click to toggle)
beanstalkd 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 628 kB
  • sloc: ansic: 7,522; sh: 390; makefile: 112; ruby: 14
file content (22 lines) | stat: -rwxr-xr-x 494 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/ruby
# Simple test to verify beanstalkd works out of the box.
# Based on the ruby-beaneater examples.

require 'json'
require 'beaneater'

@beanstalk = Beaneater.new('localhost:11300')

puts "Writing jobs"
@tube = @beanstalk.tubes["my-tube"]
@tube.put '{ "key" : "foo" }', :pri => 5
@tube.put '{ "key" : "bar" }', :delay => 3

puts "Reading back jobs"
while @tube.peek(:ready)
  job = @tube.reserve
  puts "Job key: #{JSON.parse(job.body)["key"]}"
  job.delete
end

@beanstalk.close