Added limit option for producer

This commit is contained in:
Frederic Guillot 2016-05-01 22:32:50 -04:00
parent 2579631599
commit d0fda5f1b4

View File

@ -8,9 +8,14 @@ if (php_sapi_name() !== 'cli') {
die('This script can run only from the command line.'.PHP_EOL); die('This script can run only from the command line.'.PHP_EOL);
} }
$options = getopt('', array(
'limit::',
));
$limit = ! empty($options['limit']) && ctype_digit($options['limit']) ? (int) $options['limit'] : Model\Feed\LIMIT_ALL;
$connection = new Pheanstalk(BEANSTALKD_HOST); $connection = new Pheanstalk(BEANSTALKD_HOST);
foreach (Model\Feed\get_ids() as $feed_id) { foreach (Model\Feed\get_ids($limit) as $feed_id) {
$connection $connection
->useTube(BEANSTALKD_QUEUE) ->useTube(BEANSTALKD_QUEUE)
->put($feed_id, Pheanstalk::DEFAULT_PRIORITY, Pheanstalk::DEFAULT_DELAY, BEANSTALKD_TTL); ->put($feed_id, Pheanstalk::DEFAULT_PRIORITY, Pheanstalk::DEFAULT_DELAY, BEANSTALKD_TTL);