Catalyst Job Queue - Part 2 - Issues
Differentiating between Job and HTTP Requests
The first issue raised was how can the application code determine whether a request came from the JobQueue or from a real user request.
The solution to this one is simple, let the JobQueue set a custom HTTP header, let's say X-Via-JobQueue: yes and your code can check for thae presence or absence of the header and act accordingly.
Job Results
The second problem is to find a more sensible way to deal with job results.
For now, the result is printed to STDOUT, but it would be nice to be able to store it and serve it (perhaps via HTTP) and/or send it by email.
Also, the way a job is removed from the queue based on it's results status should be configurable (i.e. make it possible to provide a list of status codes for which the job is to be remove from the queue)
One-time Jobs
Another issue is with jobs that should run a limited number of times. Currently a job will run forever at specified intervals. Running a job just one time is possible by making it return an error code, but it's clumsy. This method doesn't allow for running jobs at "now + x minutes/hours/days"
What is needed to solve this issue is the possibility to schedule a job using an at-like syntax or a natural time specification (like "next friday", using DateTime::Format::Natural)
Job Scheduling
We would also like to programtically schedule job from within the main application (initiated of course by a user HTTP request). This requires a communication channel. Or more exactly a framework for communicating between the job queue server and the http server.
Continuation Jobs
An easier way to setup a job in the job queue is to save the state of a request with Catalyst::Plugin::Continuation and have the job queue server retrieve it. Unfortunately this would also require a communication channel to transmit the session_id of the request. But it would save us the effort to setup a request.
/programming/perl/catalyst | permanent link ( writeback) | edit