ryandotsmith/queue_classic — pull request #54 by pcantrell (2012-03-28 05:17:18+00:00)
Title: Better argument structure for QC::Worker.new

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.