Giter VIP home page Giter VIP logo

Comments (4)

nesquena avatar nesquena commented on June 12, 2024

michaeldwan/stalker@3862676

from backburner.

nesquena avatar nesquena commented on June 12, 2024

The available hooks in Resque:

  • before_enqueue: Called with the job args before a job is placed on the queue.
    If the hook returns false, the job will not be placed on the queue.
  • after_enqueue: Called with the job args after a job is placed on the queue.
    Any exception raised propagates up to the code which queued the job.
  • before_dequeue: Called with the job args before a job is removed from the queue.
    If the hook returns false, the job will not be removed from the queue.
  • after_dequeue: Called with the job args after a job was removed from the queue.
    Any exception raised propagates up to the code which dequeued the job.
  • before_perform: Called with the job args before perform. If it raises
    Resque::Job::DontPerform, the job is aborted. If other exceptions
    are raised, they will be propagated up the the Resque::Failure
    backend.
  • after_perform: Called with the job args after it performs. Uncaught
    exceptions will propagate up to the Resque::Failure backend.
  • around_perform: Called with the job args. It is expected to yield in order
    to perform the job (but is not required to do so). It may handle exceptions
    thrown by perform, but any that are not caught will propagate up to the
    Resque::Failure backend.
  • on_failure: Called with the exception and job args if any exception occurs
    while performing the job (or hooks), this includes Resque::DirtyExit.

Hooks are easily implemented with superclasses or modules. A superclass could
look something like this.

class LoggedJob
  def self.before_perform_log_job(*args)
    Logger.info "About to perform #{self} with #{args.inspect}"
  end
end

class MyJob < LoggedJob
  def self.perform(*args)
     ...
  end
end

from backburner.

nesquena avatar nesquena commented on June 12, 2024

Progress here https://github.com/nesquena/backburner/tree/hooks

from backburner.

nesquena avatar nesquena commented on June 12, 2024

Finished and available in 0.2.0, see https://github.com/nesquena/backburner/blob/master/HOOKS.md for more details

from backburner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.