<commit_before># Lilmuckers_Queue

A generic multi-adapter queuing system for magento.

This module is primarily aimed at developers who need a reliable queue management system for performing asyncronous tasks. This was built because there wasn't a decent queue management module within magento or the community that filled all my requirements. This also avoids the issues that can exist with database and cron based queueing systems (such as available with Magent Enterprise)

This module has been built to be a framework for both the producer (the task adding to the queue) and the worker (the task that performs items on the queue).

Each queue has it's own handler, so multiple tasks that are a part of the same queue can easily share resources and save memory, and it is easy to create new queues with new queue handlers. Currently this is provided with only one queue (`default`) and one worker (`test`) that merely removes itself from the queue. However this should act as enough of a framework for a developer to base his or her work upon.

## Supported Queue Backends
 * beanstalkd - http://kr.github.io/beanstalkd/
  * Using Pheanstalk - https://github.com/pda/pheanstalk/

## Usage

### Creating a queue handlerm defining workersm, and sending a task to the queue
 * Define a queue in you modules `config.xml`, with the workers that exist in that queue. All workers are run as `singletons`.
  ```xml
<?xml version="1.0"?>
<config>
...
    <queues>
        <queueName>
            <label>The Queue Name</label>
            <class>module/queueHandler</class>
            <workers>
                <taskName>
                    <class>module/worker</class>
                    <method>methodName</method>
                </taskName>
            </workers>
        </queueName>
    </queues>
    
</config>
   ```
 * Call the queue handler
  ```php
<?php
$_queue = Mage::helper('lilqueue')->getQueue('queueName');
  ```
 * Generate a task, providing the task identifier, the data for the task to use, and the store to provide to the task to run with.
  ```php
<?php
$_task = Mage::helper('lilqueue')->createTask('taskName', array('data'=>'to provide', 'to'=>'the worker'), $storeToRunAs);
  ```
 * Send the task to the queue
  ```php
<?php
$_queue->addTask($_task);
  ```
  
### Workers
Workers are even easier, as they're just a method that receive the task as an argument. They must set a status to the task once they're done. <commit_msg>fixed some formatting in the readme<commit_after># Lilmuckers_Queue

A generic multi-adapter queuing system for magento.

This module is primarily aimed at developers who need a reliable queue management system for performing asyncronous tasks. This was built because there wasn't a decent queue management module within magento or the community that filled all my requirements. This also avoids the issues that can exist with database and cron based queueing systems (such as available with Magent Enterprise)

This module has been built to be a framework for both the producer (the task adding to the queue) and the worker (the task that performs items on the queue).

Each queue has it's own handler, so multiple tasks that are a part of the same queue can easily share resources and save memory, and it is easy to create new queues with new queue handlers. Currently this is provided with only one queue (`default`) and one worker (`test`) that merely removes itself from the queue. However this should act as enough of a framework for a developer to base his or her work upon.

## Supported Queue Backends
 * beanstalkd - http://kr.github.io/beanstalkd/
  * Using Pheanstalk - https://github.com/pda/pheanstalk/

## Usage

### Creating a queue handlerm defining workersm, and sending a task to the queue
 * Define a queue in you modules `config.xml`, with the workers that exist in that queue. All workers are run as `singletons`.
  ```xml
<?xml version="1.0"?>
<config>
...
    <queues>
        <queueName>
            <label>The Queue Name</label>
            <class>module/queueHandler</class>
            <workers>
                <taskName>
                    <class>module/worker</class>
                    <method>methodName</method>
                </taskName>
            </workers>
        </queueName>
    </queues>
    
</config>
   ```
 * Call the queue handler  
  ```php
<?php
$_queue = Mage::helper('lilqueue')->getQueue('queueName');
  ```
 * Generate a task, providing the task identifier, the data for the task to use, and the store to provide to the task to run with.  
  ```php
<?php
$_task = Mage::helper('lilqueue')->createTask('taskName', array('data'=>'to provide', 'to'=>'the worker'), $storeToRunAs);
  ```
 * Send the task to the queue  
  ```php
<?php
$_queue->addTask($_task);
  ```
  
### Workers
Workers are even easier, as they're just a method that receive the task as an argument. They must set a status to the task once they're done. 
{'fraction_non_alphanumeric': 0.09053999187982135, 'fraction_numerical': 0.0008120178643930166, 'mean_word_length': 3.329525483304042, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 2, '>': 51, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4364108', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1266, 'n_words': 635}