Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow processing jobs immediately in test mode #6

Closed
bkeepers opened this issue Sep 23, 2011 · 11 comments
Closed

Allow processing jobs immediately in test mode #6

bkeepers opened this issue Sep 23, 2011 · 11 comments
Labels

Comments

@bkeepers
Copy link
Owner

Instead of enqueueing a job, it should just be performed immediately.

@fbjork
Copy link

fbjork commented Sep 27, 2011

Can't wait to see some progress on this! Qu is great so far, but still needs some additional features to become awesome.

@bkeepers
Copy link
Owner Author

@fbjork Thanks, I hope to make some progress en route to RubyConf this week. Please do let me know what other features you think would make it awesome!

@luislavena
Copy link

Hello,

If I can comment, I think there are two approaches to this:

a in-memory backend that performs the enqueued job right away after enqueued,

Or, a kind of worker that do not trap signals or anything.

As example, for Resque we ended creating the following:

module Helpers
  def do_delayed_work!
    worker = SpecWorker.new('*')
    worker.work
  end
end

class SpecWorker < Resque::Worker
  def work(interval = 5, &block)
    while job = reserve
      working_on job
      perform(job, &block)
      done_working
    end
  end
end

Which is far from being pretty, but allowed us to execute the enqueued jobs.

Just my two cents.

BTW: great work on Qu, really loving it!

@bkeepers
Copy link
Owner Author

@luislavena great suggestions. You can use the existing worker to work off jobs in tests and it won't trap signals:

Qu::Worker.new('queue1', 'queue2').work_off

I was thinking I would implement test mode using hooks and work off the job after it is enqueued. I'm leaning toward this solution because it still goes through the whole stack and will make sure the args are serializable/deserializable.

@luislavena
Copy link

I was thinking I would implement test mode using hooks and work off the job after it is enqueued. I'm leaning toward this solution because it still goes through the whole stack and will make sure the args are serializable/deserializable.

Great approach, however there should be a way to control it. Under certain specs I would not like any job being performed.

Also, wouldn't Qu.enqueue and Qu::Worker.new(...).work_off exercise the args serialization?

@bkeepers
Copy link
Owner Author

Yep, enqueue and work_off would do it. That's how our tests for speakerdeck.com currently work.

On Sep 30, 2011, at 8:49 AM, Luis Lavenareply@reply.github.com wrote:

I was thinking I would implement test mode using hooks and work off the job after it is enqueued. I'm leaning toward this solution because it still goes through the whole stack and will make sure the args are serializable/deserializable.

Great approach, however there should be a way to control it. Under certain specs I would not like any job being performed.

Also, wouldn't Qu.enqueue and Qu::Worker.new(...).work_off exercise the args serialization?

Reply to this email directly or view it on GitHub:
#6 (comment)

@fbjork
Copy link

fbjork commented Oct 4, 2011

I suggest going with an in memory approach to avoid writing to Redis and adding jobs to the development queues. If not perhaps the jobs should be namespaced with the environment, i.e 'development-my_queue' or something along those lines.

@sumskyi
Copy link
Contributor

sumskyi commented Nov 24, 2011

how about https://gist.github.com/1391531 approach?

@bkeepers
Copy link
Owner Author

@sumskyi: looks like a good start to me. Want to submit a pull request with it?

@sumskyi
Copy link
Contributor

sumskyi commented Nov 28, 2011

@bkeepers: added #36

@bkeepers
Copy link
Owner Author

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants