Sha256: a04430e09fbc76b79267efc95c2ace25d593b9004f41b074a69fabf0f36f15c2
Contents?: true
Size: 1.35 KB
Versions: 4
Compression:
Stored size: 1.35 KB
Contents
APP_FILE = 'lib/beanstalkd_view.rb' APP_CLASS = 'BeanstalkdView::Server' require 'sinatra/assetpack/rake' require "bundler/gem_tasks" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) task :default => :spec require 'beaneater' require 'json' namespace :beanstalkd_view do TEST_QUEUES = ['tube_sock', 'test_tube', 'tube_top', 'inner_tube'] # Randomly enqueue elements to test queues task :enqueue_test do host = "localhost" port = 11300 beanstalk = Beaneater::Pool.new([ "#{host}:#{port}" ]) # Loop flooding the queues with jobs while true tube_name = TEST_QUEUES.sample pri = 65536 delay = 0 ttr = 120 tube = beanstalk.tubes[tube_name] tube.put '{}', :pri => pri, :delay => delay, :ttr => ttr puts "Enqueued Job to #{tube_name}" end end # Randomly pull elements from test queues task :pull_test do host = "localhost" port = 11300 beanstalk = Beaneater::Pool.new([ "#{host}:#{port}" ]) while true tube_name = TEST_QUEUES.sample begin beanstalk.tubes.watch!(tube_name) job = beanstalk.tubes.reserve(1) if job puts "Pulled Job #{job} from #{tube_name}" job.delete end rescue Exception => ex puts "Exception while pulling job from #{tube_name}: #{ex}" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
beanstalkd_view-1.1.3 | Rakefile |
beanstalkd_view-1.1.2 | Rakefile |
beanstalkd_view-1.1.1 | Rakefile |
beanstalkd_view-1.1.0 | Rakefile |