added schedule to README

This commit is contained in:
Ilan Steemers
2015-06-25 20:30:13 +02:00
parent d5d529f874
commit e2f7f1e5bf
4 changed files with 29 additions and 10 deletions

View File

@@ -31,8 +31,15 @@ You can monitor basic information about all the connected clusters by running `
![qmonitor command](http://i.imgur.com/5cm7hdP.png)
###Admin integration
Django Q registers itself with the admin page to show failed and successful tasks.
Django Q registers itself with the admin page to show failed, successful and scheduled tasks.
From there task results can be read or deleted. If necessary, failed tasks can be reintroduced to the queue.
Schedules be created and their results monitored.
![q admin](http://i.imgur.com/WTZkW9r.png)
###Schedules
Scheduled tasks are a django model and can be created through the admin interface or by creating a Schedule instance directly.
Like the Async Task, a Schedule can take an optional hook keyword and is used as a template to create the actual task package at the scheduled time.
If a result task is available in the database, it can be accessed through the Schedule instance's `result()` method.
### Signed Tasks
Tasks are first pickled to Json and then signed using Django's own signing module before being sent to a Redis list. This ensures that task packages on the Redis server can only be excuted and read by clusters and django servers who share the same secret key.

View File

@@ -53,9 +53,20 @@ running ``./manage.py qmonitor``
Admin integration
~~~~~~~~~~~~~~~~~
Django Q registers itself with the admin page to show failed and
successful tasks. From there task results can be read or deleted. If
necessary, failed tasks can be reintroduced to the queue.
Django Q registers itself with the admin page to show failed, successful
and scheduled tasks. From there task results can be read or deleted. If
necessary, failed tasks can be reintroduced to the queue. Schedules be
created and their results monitored. |q admin|
Schedules
~~~~~~~~~
Scheduled tasks are a django model and can be created through the admin
interface or by creating a Schedule instance directly. Like the Async
Task, a Schedule can take an optional hook keyword and is used as a
template to create the actual task package at the scheduled time. If a
result task is available in the database, it can be accessed through the
Schedule instance's ``result()`` method.
Signed Tasks
~~~~~~~~~~~~
@@ -119,3 +130,4 @@ I'll add to this README while I'm developing the various parts.
.. |image0| image:: https://travis-ci.org/Koed00/django-q.svg?branch=master
:target: https://travis-ci.org/Koed00/django-q
.. |q admin| image:: http://i.imgur.com/WTZkW9r.png

View File

@@ -1,4 +1,4 @@
from django_q.models import Task
from django_q.models import Task, Schedule
from django_q.core import async
default_app_config = 'django_q.apps.DjangoQConfig'

View File

@@ -79,10 +79,10 @@ class Failure(Task):
class Schedule(models.Model):
func = models.CharField(max_length=256)
hook = models.CharField(max_length=256, null=True, blank=True)
args = models.CharField(max_length=256, null=True, blank=True)
kwargs = models.CharField(max_length=256, null=True, blank=True)
func = models.CharField(max_length=256, help_text='e.g. module.tasks.function')
hook = models.CharField(max_length=256, null=True, blank=True, help_text='e.g. module.tasks.result_function')
args = models.CharField(max_length=256, null=True, blank=True, help_text=_("e.g. 1, 2, 'John'"))
kwargs = models.CharField(max_length=256, null=True, blank=True, help_text=_("e.g. x=1, y=2, name='John'"))
ONCE = 'O'
HOURLY = 'H'
DAILY = 'D'
@@ -100,7 +100,7 @@ class Schedule(models.Model):
(YEARLY, _('Yearly')),
)
schedule_type = models.CharField(max_length=1, choices=TYPE, default=TYPE[0][0], verbose_name=_('Schedule Type'))
repeats = models.SmallIntegerField(default=-1, verbose_name=_('Repeats'))
repeats = models.SmallIntegerField(default=-1, verbose_name=_('Repeats'), help_text=_('n = n times, -1 = forever'))
next_run = models.DateTimeField(verbose_name=_('Next Run'), default=timezone.now, null=True)
task = models.CharField(max_length=100, editable=False, null=True)