Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #165 from juriansluiman/update-dep
Browse files Browse the repository at this point in the history
Raise minimum dependency
  • Loading branch information
Jurian Sluiman committed Aug 10, 2015
2 parents 97e16e9 + 6310d75 commit 9a50503
Show file tree
Hide file tree
Showing 75 changed files with 265 additions and 240 deletions.
18 changes: 13 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
sudo: false

language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
cache:
directories:
- $HOME/.composer/cache
- vendor

matrix:
fast_finish: true
include:
- php: 5.5
- php: 5.6
- php: 7

before_script:
- composer self-update
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.5.0

- [BC] Minimum dependency has been raised to PHP 5.5
- Project has been migrated to PSR-4

# 0.4.2

- Jobs (and execution result) weren't removed from the (reused) WorkerEvent until a new job was processed. These
Expand Down
20 changes: 2 additions & 18 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,13 @@
namespace SlmQueue;

use Zend\Loader;
use Zend\ModuleManager\Feature;
use Zend\ModuleManager\Feature\ConfigProviderInterface;

/**
* SlmQueue
*/
class Module implements
Feature\AutoloaderProviderInterface,
Feature\ConfigProviderInterface
class Module implements ConfigProviderInterface
{
/**
* {@inheritDoc}
*/
public function getAutoloaderConfig()
{
return array(
Loader\AutoloaderFactory::STANDARD_AUTOLOADER => array(
Loader\StandardAutoloader::LOAD_NS => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}

/**
* {@inheritDoc}
*/
Expand Down
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": ">=5.5",
"zendframework/zend-servicemanager": "~2.2",
"zendframework/zend-stdlib": "~2.2"
},
Expand All @@ -42,11 +42,16 @@
}
},
"autoload": {
"psr-0": {
"SlmQueue": "src/"
"psr-4": {
"SlmQueue\\": "src/"
},
"classmap": [
"./Module.php"
]
},
"autoload-dev": {
"psr-4": {
"SlmQueueTest\\": "tests/"
}
}
}
110 changes: 64 additions & 46 deletions config/module.config.php
Original file line number Diff line number Diff line change
@@ -1,69 +1,87 @@
<?php

return array(
'service_manager' => array(
'factories' => array(
'SlmQueue\Job\JobPluginManager' => 'SlmQueue\Factory\JobPluginManagerFactory',
'SlmQueue\Listener\StrategyPluginManager' => 'SlmQueue\Factory\StrategyPluginManagerFactory',
'SlmQueue\Queue\QueuePluginManager' => 'SlmQueue\Factory\QueuePluginManagerFactory'
),
),
use SlmQueue\Factory\JobPluginManagerFactory;
use SlmQueue\Factory\QueueControllerPluginFactory;
use SlmQueue\Factory\QueuePluginManagerFactory;
use SlmQueue\Factory\StrategyPluginManagerFactory;
use SlmQueue\Job\JobPluginManager;
use SlmQueue\Queue\QueuePluginManager;
use SlmQueue\Strategy\AttachQueueListenersStrategy;
use SlmQueue\Strategy\Factory\AttachQueueListenersStrategyFactory;
use SlmQueue\Strategy\Factory\LogJobStrategyFactory;
use SlmQueue\Strategy\FileWatchStrategy;
use SlmQueue\Strategy\InterruptStrategy;
use SlmQueue\Strategy\LogJobStrategy;
use SlmQueue\Strategy\MaxMemoryStrategy;
use SlmQueue\Strategy\MaxPollingFrequencyStrategy;
use SlmQueue\Strategy\MaxRunsStrategy;
use SlmQueue\Strategy\ProcessQueueStrategy;
use SlmQueue\Strategy\StrategyPluginManager;

'controller_plugins' => array(
'factories' => array(
'queue' => 'SlmQueue\Factory\QueueControllerPluginFactory'
),
),
return [
'service_manager' => [
'factories' => [
JobPluginManager::class => JobPluginManagerFactory::class,
StrategyPluginManager::class => StrategyPluginManagerFactory::class,
QueuePluginManager::class => QueuePluginManagerFactory::class
],
],

'slm_queue' => array(
'controller_plugins' => [
'factories' => [
'queue' => QueueControllerPluginFactory::class
],
],

'slm_queue' => [
/**
* Worker Strategies
*/
'worker_strategies' => array(
'default' => array( // per worker
'SlmQueue\Strategy\AttachQueueListenersStrategy', // attaches strategies per queue
'SlmQueue\Strategy\MaxRunsStrategy' => array('max_runs' => 100000),
'SlmQueue\Strategy\MaxMemoryStrategy' => array('max_memory' => 100 * 1024 * 1024),
'SlmQueue\Strategy\InterruptStrategy',
),
'queues' => array( // per queue
'default' => array(
'SlmQueue\Strategy\ProcessQueueStrategy',
)
),
),
'worker_strategies' => [
'default' => [ // per worker
AttachQueueListenersStrategy::class, // attaches strategies per queue
MaxRunsStrategy::class => ['max_runs' => 100000],
MaxMemoryStrategy::class => ['max_memory' => 100 * 1024 * 1024],
InterruptStrategy::class,
],
'queues' => [ // per queue
'default' => [
ProcessQueueStrategy::class,
]
],
],

/**
* Queue configuration
*/
'queues' => array(),
'queues' => [],

/**
* Job manager configuration
*/
'job_manager' => array(),
'job_manager' => [],

/**
* Queue manager configuration
*/
'queue_manager' => array(),
'queue_manager' => [],

/**
* Strategy manager configuration
*/
'strategy_manager' => array(
'invokables' => array(
'SlmQueue\Strategy\ProcessQueueStrategy' => 'SlmQueue\Strategy\ProcessQueueStrategy',
'SlmQueue\Strategy\InterruptStrategy' => 'SlmQueue\Strategy\InterruptStrategy',
'SlmQueue\Strategy\MaxRunsStrategy' => 'SlmQueue\Strategy\MaxRunsStrategy',
'SlmQueue\Strategy\MaxMemoryStrategy' => 'SlmQueue\Strategy\MaxMemoryStrategy',
'SlmQueue\Strategy\FileWatchStrategy' => 'SlmQueue\Strategy\FileWatchStrategy',
'SlmQueue\Strategy\MaxPollingFrequencyStrategy' => 'SlmQueue\Strategy\MaxPollingFrequencyStrategy',
),
'factories' => array(
'SlmQueue\Strategy\AttachQueueListenersStrategy' => 'SlmQueue\Strategy\Factory\AttachQueueListenersStrategyFactory',
'SlmQueue\Strategy\LogJobStrategy' => 'SlmQueue\Strategy\Factory\LogJobStrategyFactory',
)
),
)
);
'strategy_manager' => [
'invokables' => [
ProcessQueueStrategy::class => ProcessQueueStrategy::class,
InterruptStrategy::class => InterruptStrategy::class,
MaxRunsStrategy::class => MaxRunsStrategy::class,
MaxMemoryStrategy::class => MaxMemoryStrategy::class,
FileWatchStrategy::class => FileWatchStrategy::class,
MaxPollingFrequencyStrategy::class => MaxPollingFrequencyStrategy::class,
],
'factories' => [
AttachQueueListenersStrategy::class => AttachQueueListenersStrategyFactory::class,
LogJobStrategy::class => LogJobStrategyFactory::class,
]
],
]
];
88 changes: 46 additions & 42 deletions config/slm_queue.global.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
* forget to remove the .dist extension from the file), and configure it as you want
*/

return array(
'slm_queue' => array(
use SlmQueue\Strategy\LogJobStrategy;
use SlmQueue\Strategy\MaxMemoryStrategy;
use SlmQueue\Strategy\ProcessQueueStrategy;

return [
'slm_queue' => [
/**
* Allow to configure a specific queue.
*
* Available options depends on the queue factory
*/
'queues' => array(),
'queues' => [],

/**
* This block is use to register and configure strategies to the worker event manager. The default key holds any
Expand All @@ -22,83 +26,83 @@ return array(
* Note that module.config.php defines a few defaults and that configuration where the value is not an array
* will be ignored (thus allows you to disable preconfigured strategies).
*
* 'worker_strategies' => array(
* 'default' => array( // per worker
* 'worker_strategies' => [
* 'default' => [ // per worker
* // Would disable the pre configured max memory strategy
* 'SlmQueue\Strategy\MaxMemoryStrategy' => null
* MaxMemoryStrategy::class => null
* // Reconfigure the pre configured max memory strategy to use 250Mb max
* 'SlmQueue\Strategy\MaxMemoryStrategy' => array('max_memory' => 250 * 1024 * 1024)
* ),
* ),
* MaxMemoryStrategy::class => ['max_memory' => 250 * 1024 * 1024]
* ],
* ],
*
* As queue processing is handled by strategies it is important that for each queue a ProcessQueueStrategy
* (a strategy that listens to WorkerEvent::EVENT_PROCESS) is registered. By default SlmQueue does handles that
* for the queue called 'default'.
*
* 'worker_strategies' => array(
* 'queues' => array(
* 'my-queue' => array(
* 'SlmQueue\Strategy\ProcessQueueStrategy',
* )
* ),
* ),
* 'worker_strategies' => [
* 'queues' => [
* 'my-queue' => [
* ProcessQueueStrategy::class,
* ]
* ],
* ],
*/
'worker_strategies' => array(
'default' => array( // per worker
),
'queues' => array( // per queue
'default' => array(
),
),
),
'worker_strategies' => [
'default' => [ // per worker
],
'queues' => [ // per queue
'default' => [
],
],
],

/**
* Allow to configure the plugin manager that manages strategies. This works like any other
* PluginManager in Zend Framework 2.
*
* Add you own or override existing factories
*
* 'strategy_manager' => array(
* 'factories' => array(
* 'SlmQueue\Strategy\LogJobStrategy' => 'MyVeryOwn\LogJobStrategyFactory',
* )
* ),
* 'strategy_manager' => [
* 'factories' => [
* LogJobStrategy::class => 'MyVeryOwn\LogJobStrategyFactory',
* ]
* ],
*/
'strategy_manager' => array(),
'strategy_manager' => [],

/**
* Allow to configure dependencies for jobs that are pulled from any queue. This works like any other
* PluginManager in Zend Framework 2. For instance, if you want to inject something into every job using
* a factory, just adds an element into the "factories" array, with the key being the FQCN of the job,
* and the value the factory:
*
* 'job_manager' => array(
* 'factories' => array(
* 'job_manager' => [
* 'factories' => [
* 'Application\Job\UserJob' => 'Application\Factory\UserJobFactory'
* )
* )
* ]
* ]
*
* Therefore, the job will be created through the factory (the identifier and content of the job will be
* automatically set after creation). Note that this plugin manager is configured as such it automatically
* add any unknown classes to the invokables list. This means you should only add factories and/or abstract
* factories here.
*/
'job_manager' => array(),
'job_manager' => [],

/**
* Allow to add queues. You need to have at least one queue. This works like any other PluginManager in
* Zend Framework 2. For instance, if you have a queue whose name is "email", you can add it as an
* invokable this way:
*
* 'queue_manager' => array(
* 'invokables' => array(
* 'queue_manager' => [
* 'invokables' => [
* 'email' => 'Application\Queue\MyQueue'
* )
* )
* ]
* ]
*
* Please note that you can find built-in factories for several queue systems (Beanstalk, Amazon Sqs...)
* in SlmQueueSqs and SlmQueueBeanstalk
*/
'queue_manager' => array()
),
);
'queue_manager' => []
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function processAction()
* @param array $messages
* @return string
*/
protected function formatOutput($queueName, array $messages = array())
protected function formatOutput($queueName, array $messages = [])
{
$messages = implode("\n", array_map(function ($m) {
return sprintf(' - %s', $m);
Expand Down
Loading

0 comments on commit 9a50503

Please sign in to comment.