@@ -19,6 +19,12 @@ |
||
| 19 | 19 | $this->overwrite = true; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | + /** |
|
| 23 | + * @param boolean $autostart |
|
| 24 | + * @param boolean $autorestart |
|
| 25 | + * @param string $appId |
|
| 26 | + * @param string $destination |
|
| 27 | + */ |
|
| 22 | 28 | public function generate(array $workers, $autostart, $autorestart, $server, $appId, $destination, OutputInterface $output) |
| 23 | 29 | { |
| 24 | 30 | foreach($workers as $worker => $data) |
@@ -72,7 +72,7 @@ |
||
| 72 | 72 | user=www-data |
| 73 | 73 | autostart=$autostart |
| 74 | 74 | autorestart=$autorestart |
| 75 | -TXT; |
|
| 75 | +txt; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | private function booleanToString($value) |
@@ -20,30 +20,30 @@ |
||
| 20 | 20 | |
| 21 | 21 | private function registerAmqpServices(Container $app) |
| 22 | 22 | { |
| 23 | - $app['amqp.client'] = function ($c) { |
|
| 23 | + $app['amqp.client'] = function($c) { |
|
| 24 | 24 | return new Pecl($c['configuration']); |
| 25 | 25 | }; |
| 26 | 26 | |
| 27 | - $app['amqp.workerProvider'] = function ($c) { |
|
| 27 | + $app['amqp.workerProvider'] = function($c) { |
|
| 28 | 28 | return new Pimple($c); |
| 29 | 29 | }; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | private function registerConsumers(Container $app) |
| 33 | 33 | { |
| 34 | - $app['amqp.consumers.simple'] = function () { |
|
| 34 | + $app['amqp.consumers.simple'] = function() { |
|
| 35 | 35 | return new Consumers\Simple(); |
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | - $app['amqp.consumers.insomniac'] = function () { |
|
| 38 | + $app['amqp.consumers.insomniac'] = function() { |
|
| 39 | 39 | return new Consumers\Insomniac(); |
| 40 | 40 | }; |
| 41 | 41 | |
| 42 | - $app['amqp.consumers.retry'] = $app->protect(function (Container $c, $retries = null) { |
|
| 42 | + $app['amqp.consumers.retry'] = $app->protect(function(Container $c, $retries = null) { |
|
| 43 | 43 | return new Consumers\Retry($retries); |
| 44 | 44 | }); |
| 45 | 45 | |
| 46 | - $app['amqp.consumers.instantRetry'] = $app->protect(function (Container $c, $retries, $delayInSeconds) { |
|
| 46 | + $app['amqp.consumers.instantRetry'] = $app->protect(function(Container $c, $retries, $delayInSeconds) { |
|
| 47 | 47 | return new Consumers\InstantRetry($retries, $delayInSeconds); |
| 48 | 48 | }); |
| 49 | 49 | } |
@@ -25,12 +25,12 @@ |
||
| 25 | 25 | protected function configure() |
| 26 | 26 | { |
| 27 | 27 | $this->setName('list') |
| 28 | - ->addArgument( |
|
| 29 | - 'workerNamePattern', |
|
| 30 | - InputArgument::OPTIONAL, |
|
| 31 | - 'Regex pattern of the worker name', |
|
| 32 | - null |
|
| 33 | - ) |
|
| 28 | + ->addArgument( |
|
| 29 | + 'workerNamePattern', |
|
| 30 | + InputArgument::OPTIONAL, |
|
| 31 | + 'Regex pattern of the worker name', |
|
| 32 | + null |
|
| 33 | + ) |
|
| 34 | 34 | ->setDescription('List AMQP workers'); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $workerNamePattern = $input->getArgument('workerNamePattern'); |
| 40 | 40 | |
| 41 | - if(!empty($workerNamePattern)) |
|
| 41 | + if( ! empty($workerNamePattern)) |
|
| 42 | 42 | { |
| 43 | 43 | $comment = sprintf('List of worker with following pattern: %s', $workerNamePattern); |
| 44 | 44 | $services = $this->workerProvider->listWithRegexFilter($workerNamePattern); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | $output->writeln(sprintf('<comment>%s</comment>', $comment)); |
| 53 | 53 | |
| 54 | - if(empty($services) || !is_array($services)) |
|
| 54 | + if(empty($services) || ! is_array($services)) |
|
| 55 | 55 | { |
| 56 | 56 | $output->writeln('<error>No worker found</error>'); |
| 57 | 57 | return; |
@@ -6,12 +6,10 @@ |
||
| 6 | 6 | use Puzzle\PrefixedConfiguration; |
| 7 | 7 | |
| 8 | 8 | use Puzzle\AMQP\Client; |
| 9 | -use Puzzle\AMQP\Messages; |
|
| 10 | 9 | use Puzzle\AMQP\Workers\MessageAdapter; |
| 11 | 10 | use Psr\Log\LoggerAwareTrait; |
| 12 | 11 | use Psr\Log\NullLogger; |
| 13 | 12 | use Puzzle\AMQP\WritableMessage; |
| 14 | -use Puzzle\AMQP\Collections; |
|
| 15 | 13 | |
| 16 | 14 | class Pecl implements Client |
| 17 | 15 | { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | private function ensureIsConnected() |
| 34 | 34 | { |
| 35 | - if(! $this->channel instanceof \AMQPChannel) |
|
| 35 | + if( ! $this->channel instanceof \AMQPChannel) |
|
| 36 | 36 | { |
| 37 | 37 | $configuration = new PrefixedConfiguration($this->configuration, 'amqp/broker'); |
| 38 | 38 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | $ex = $this->getExchange($exchangeName); |
| 63 | 63 | } |
| 64 | - catch (\Exception $e) |
|
| 64 | + catch(\Exception $e) |
|
| 65 | 65 | { |
| 66 | 66 | $this->logMessage($exchangeName, $message); |
| 67 | 67 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $message->packAttributes() |
| 95 | 95 | ); |
| 96 | 96 | } |
| 97 | - catch (\Exception $e) |
|
| 97 | + catch(\Exception $e) |
|
| 98 | 98 | { |
| 99 | 99 | $this->logMessage($ex->getName(), $message); |
| 100 | 100 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | $ex = new \AMQPExchange($this->channel); |
| 112 | 112 | |
| 113 | - if(!empty($exchangeName)) |
|
| 113 | + if( ! empty($exchangeName)) |
|
| 114 | 114 | { |
| 115 | 115 | $ex->setName($exchangeName); |
| 116 | 116 | $ex->setType($type); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | public function applyHooks(MessageHookCollection $messageHookCollection) |
| 67 | 67 | { |
| 68 | - if(!empty($messageHookCollection)) |
|
| 68 | + if( ! empty($messageHookCollection)) |
|
| 69 | 69 | { |
| 70 | 70 | foreach($messageHookCollection as $messageHook) |
| 71 | 71 | { |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | { |
| 152 | 152 | $retryHeader = $this->getHeader(\Puzzle\AMQP\Consumers\Retry::DEFAULT_RETRY_HEADER); |
| 153 | 153 | |
| 154 | - return (!empty($retryHeader) && (int) $retryHeader === $retryOccurence); |
|
| 154 | + return ( ! empty($retryHeader) && (int) $retryHeader === $retryOccurence); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | public function getRoutingKeyFromHeader() |
| 158 | 158 | { |
| 159 | 159 | $headers = $this->getHeaders(); |
| 160 | 160 | |
| 161 | - if(! array_key_exists('routing_key', $headers)) |
|
| 161 | + if( ! array_key_exists('routing_key', $headers)) |
|
| 162 | 162 | { |
| 163 | 163 | return null; |
| 164 | 164 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | |
| 26 | 26 | $hooks = $this->workerContext->getMessageHooks(); |
| 27 | 27 | |
| 28 | - if(!empty($hooks)) |
|
| 28 | + if( ! empty($hooks)) |
|
| 29 | 29 | { |
| 30 | 30 | $message->applyHooks($hooks); |
| 31 | 31 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | public function deployInstances($numberOfInstance) |
| 101 | 101 | { |
| 102 | - if(! empty($numberOfInstance)) |
|
| 102 | + if( ! empty($numberOfInstance)) |
|
| 103 | 103 | { |
| 104 | 104 | $this->instances = (int) $numberOfInstance; |
| 105 | 105 | } |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | public function deployOn($servers) |
| 116 | 116 | { |
| 117 | - if(! empty($servers)) |
|
| 117 | + if( ! empty($servers)) |
|
| 118 | 118 | { |
| 119 | - if(! is_array($servers)) |
|
| 119 | + if( ! is_array($servers)) |
|
| 120 | 120 | { |
| 121 | 121 | $servers = [$servers]; |
| 122 | 122 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | { |
| 28 | 28 | $retryHeader = $this->getHeader(\Puzzle\AMQP\Consumers\Retry::DEFAULT_RETRY_HEADER); |
| 29 | 29 | |
| 30 | - return (!empty($retryHeader) && (int) $retryHeader === $retryOccurence); |
|
| 30 | + return ( ! empty($retryHeader) && (int) $retryHeader === $retryOccurence); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function applyHooks(MessageHookCollection $messageHookCollection) |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | public function setBody($body) |
| 75 | 75 | { |
| 76 | - if(! is_array($body)) |
|
| 76 | + if( ! is_array($body)) |
|
| 77 | 77 | { |
| 78 | 78 | $body = array($body); |
| 79 | 79 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $timestamp = (new \DateTime("now"))->getTimestamp(); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - return array_map(function ($value) use($timestamp) { |
|
| 129 | + return array_map(function($value) use($timestamp) { |
|
| 130 | 130 | |
| 131 | 131 | if($value instanceof \Closure) |
| 132 | 132 | { |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $writableMessage = new static($routingKey); |
| 212 | 212 | |
| 213 | 213 | $decodedBody = $readableMessage->getDecodedBody(); |
| 214 | - if(! is_array($decodedBody)) |
|
| 214 | + if( ! is_array($decodedBody)) |
|
| 215 | 215 | { |
| 216 | 216 | $decodedBody = array($decodedBody); |
| 217 | 217 | } |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $skippedAttributes = array('timestamp', 'headers', 'app_id', 'routing_key'); |
| 225 | 225 | foreach($attributes as $attributeName => $value) |
| 226 | 226 | { |
| 227 | - if(! in_array($attributeName, $skippedAttributes)) |
|
| 227 | + if( ! in_array($attributeName, $skippedAttributes)) |
|
| 228 | 228 | { |
| 229 | 229 | $writableMessage->setAttribute($attributeName, $value); |
| 230 | 230 | } |