juriansluiman/SlmQueue — pull request #52 by bakura10 (2013-06-05 07:54:58+00:00)
Title: Allow to normalize options

This PR allows to provide an easy way to normalize options in controller. This was needed because in SQS, for instance, the params in the console are shorter name using camelCase (example: maxJobs), while those needs to be converted to name that map the underlying queue system and using underscore_separated as this is ZF2 convention for options (this needs to be converted to max_number_of_messages).

Because of this, and to solve more elegantly my problem of SQS, I suggest:

- We add the BatchableQueue interface in SlmQueue with batchPop, batchPush and batchDelete. Most of those can be emulated in most queue systems.
- We standardize the name for the "maxJobs" options in controller. This way, we could modify the controller this way:

```php
public function processAction()
{
$options = $this->params()->fromRoute();
$queue = $options['queue'];

try {
if ($options['maxJobs'] === 1) {
$options = $this->normalizeOptions($options);
$result = $this->worker->processQueue($queue, $options);
} else {
$options = $this->normalizeOptions($options);
$result = $this->worker->processBatchQueue($queue, $options);
}
}

return sprintf(
"Finished worker for queue '%s' with %s jobs\n",
$queue,
$result
);
}
```

We introduce a new processBatchQueue in Worker.

Thoughts @juriansluiman @basz ?