From: Brandon Keepers <bran...@opensoul.org>
Date: Mon, 10 Oct 2011 23:37:00 -0400
Subject: Hooks api
Hello Qu Comrades (all 3 of you), I've started working on an implementation of hooks and thought I would get some feedback before going any further. https://github.com/bkeepers/qu/compare/master…hooks (https://github.com/bkeepers/qu/compare/master...hooks) To summarize the major changes: Jobs must now extend Qu::Job. This is something I debated about a lot in the initial implementation of Qu. I initially implemented it as a subclass of Qu::Job, but then decided follow Resque and make jobs simply a class with a perform class method for simplicity's sake. I have since changed my mind and think there's a lot of power in using richer objects for jobs. The Qu:Job class currently implements 4 hooks (perform, complete, release, failure). Others will be coming soon, but I still need to figure out some implementation details. A hook is a method that is called before, after, or around one of the events. Calling `halt` in a before hook will prevent the original action from occurring (example: `halt` in a before_failure hook will prevent the job from being marked as failed) and will stop all other hooks. Here are some examples of what a job using hooks will look like: class MyJob < Qu::Job around_perform :timeout before_failure :ignore_annoying_errors def initialize(thing_id) def perform private def notify_before_perform def notify_after_perform def ignore_annoying_errors(e) def timeout So, what do you think so far? Anything you would do differently? Thanks, You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||