My favorites | Sign in
Project Logo
                
Code license: New BSD License
Labels: Kohana, Queue, Module
Show all Featured downloads:
kohana_queue_v1.2.zip
Feeds:
People details
Project owners:
  contractfrombelow

Kohana Queue Module Documentation

The Kohana Queue Module was created by SocialAmp. It is released under the BSD license as detailed in the license.txt file included in each release.

Architecture

The Kohana Queue Module runs on a client server methodology. A daemon server runs in the background on your application server scanning a database for Kohana jobs to run. When it finds a job to run, it loads the calling Kohana application, runs the task, and deletes it from the queue table.

The Kohana Queue Module has a simple API for applications to add jobs to the queue. It has job priorities so urgent jobs can run before non-essential jobs.

Any Kohana application on your server can use the Module. Just add it to the $config['modules'] array as described in the main Kohana Documentation.

The Daemon

The daemon is a stand-alone Kohana CLI application.

Configuration

Besides the regular Kohana config files, there is one custom config file that needs to be customized, if you wish to change the default values, application/config/queue.php. The options are:

In addition, you will need to set the following config files, database.php, log.php

Running The Daemon

To run the daemon on your server, change to the directory you installed the module, and run php index.php "application_queue/run". Alternatively, you could set this up as a startup item based on your system.

The Module

The module has one method to add jobs the queue:

Task_Queue::add()

This method adds a task to the queue. It has the following parameters.

Below is some example code to use the Module.

for ($i = 0; $i <= 20; $i++) {

$value = rand(0, 11); if (Task_Queue::add('Application_Queue_Controller', 'sleep', array('value' => $value), $value))
echo '<p>Task added to the queue</p>';
else
echo '<p>Could not add the task to the queue</p>';
}

This would add the sleep() method from the Application_Queue_Controller class to the queue, with a random sleep value.









Hosted by Google Code