Coder Social home page Coder Social logo

Rewrite the jobs data model about rq HOT 1 CLOSED

rq avatar rq commented on September 24, 2024
Rewrite the jobs data model

from rq.

Comments (1)

nvie avatar nvie commented on September 24, 2024

Implementation steps

Baby-steps to the final implementation:

  • Get rid of the DelayedResult object (there can be a result key underneath the newly-to-create job key)
  • When Jobs instantiate, generate a uuid for them. This is the job ID.
  • Jobs are not actually created in Redis until they are enqueued. Before enqueuing, no Job keys will be written to Redis.
  • When enqueue'ing, first write out the job into its own key, then push the job ID onto the given queue.
  • When dequeue'ing, pop the job ID from the given queue. If there still exists a job key for that job in Redis, unpickle it and execute it. If not, warn about it and simply ignore the job ID.

The job key

A "job key" is a Redis hash with a key of the form rq:job:6be1faf9-69bf-4248-931a-ff6c4e37074b. The hash has the following keys:

  • data: the actual payload of the job. It contains the pickled (func, args, kwargs) tuple.
  • origin: the original queue the job has first been submitted to.
  • enqueued_at: the last enqueue datetime (in universal time)
  • created_at: the date time at which the job was first created (in universal time)
  • exc_info (optional): exception information about the last failure
  • result (optional): if the job returned some value, the result will be serialised (pickled) into this hash key

Future work

  • To "cancel" a job, simply remove the job key.

from rq.

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.