Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed Worker.new to accept an options hash (with all values optiona…

…l), or no args at all (to make everything default).
  • Loading branch information...
commit e1b791a909f78d117c780fbc3f1f1a669e345e47 1 parent 1ac0d65
@pcantrell pcantrell authored
Showing with 14 additions and 1 deletion.
  1. +14 −1 lib/queue_classic/worker.rb
View
15 lib/queue_classic/worker.rb
@@ -1,7 +1,20 @@
module QC
class Worker
- def initialize(q_name, top_bound, fork_worker, listening_worker, max_attempts)
+ def initialize(*args)
+ if args.length == 5
+ q_name, top_bound, fork_worker, listening_worker, max_attempts = *args
+ elsif args.length <= 1
+ opts = args.first || {}
+ q_name = opts[:q_name] || QC::QUEUE
+ top_bound = opts[:top_bound] || QC::TOP_BOUND
+ fork_worker = opts[:fork_worker] || QC::FORK_WORKER
+ listening_worker = opts[:listening_worker] || QC::LISTENING_WORKER
+ max_attempts = opts[:max_attempts] || QC::MAX_LOCK_ATTEMPTS
+ else
+ raise ArgumentError, 'wrong number of arguments (expected no args, an options hash, or 5 separate args)'
+ end
+
log("worker initialized")
@running = true
Please sign in to comment.
Something went wrong with that request. Please try again.