Better argument structure for QC::Worker.new #54

Merged
merged 1 commit into from Mar 28, 2012

Projects

None yet

2 participants

@pcantrell
Contributor

The docs say that I should be able to just do QC::Worker.new.start to fire up a consumer, but that fails b/c Worker.new requires 5 args.

Having the 5 args all in order with no defaults didn't seem very maintainable, so here's a patch to make it accept an options hash, e.g.:

QC::Worker.new(q_name: 'thingers', top_bound: 3, fork_worker: true, listening_worker: true, max_attempts: 5)

…or to use some defaults:

QC::Worker.new(q_name: 'thingers', listening_worker: true)

…or to use all defaults:

QC::Worker.new

It also still works with the original 5-argument scheme, for backwards compatibility.

What do you think? I'm new to the code, so I may be missing something. Feel free to reject the pull request if this doesn't actually make sense.

@pcantrell pcantrell Changed Worker.new to accept an options hash (with all values optiona…
…l), or no args at all (to make everything default).
e1b791a
@ryandotsmith
Contributor

Yes! @mfine and I were just talking about how the args to the worker are a bit cumbersome. This patch solves a real problem. Thanks for taking care of this.

@ryandotsmith ryandotsmith merged commit b4723ab into QueueClassic:master Mar 28, 2012
@pcantrell
Contributor

You bet. Glad it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment