@@ -21,14 +21,14 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public function generate(array $workers, $autostart, $autorestart, $server, $appId, $destination, OutputInterface $output) |
| 23 | 23 | { |
| 24 | - foreach($workers as $worker => $data) |
|
| 24 | + foreach ($workers as $worker => $data) |
|
| 25 | 25 | { |
| 26 | - if( ! $data['isDeploymentAllowed']) |
|
| 26 | + if (!$data['isDeploymentAllowed']) |
|
| 27 | 27 | { |
| 28 | 28 | continue; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if( ! in_array($server, $data['servers'])) |
|
| 31 | + if (!in_array($server, $data['servers'])) |
|
| 32 | 32 | { |
| 33 | 33 | continue; |
| 34 | 34 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $this->filesystem->write($filename, $configuration, $this->overwrite); |
| 46 | 46 | |
| 47 | 47 | $message = sprintf('%s', $destination . $filename); |
| 48 | - if($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) |
|
| 48 | + if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) |
|
| 49 | 49 | { |
| 50 | 50 | $message = sprintf("<comment>%s%s</comment>\n%s\n", $destination, $filename, $configuration); |
| 51 | 51 | } |
@@ -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 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | public function addHeaders(array $headers) |
| 106 | 106 | { |
| 107 | - foreach($headers as $name => $value) |
|
| 107 | + foreach ($headers as $name => $value) |
|
| 108 | 108 | { |
| 109 | 109 | $this->addHeader($name, $value); |
| 110 | 110 | } |
@@ -121,14 +121,14 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | public function packAttributes($timestamp = false) |
| 123 | 123 | { |
| 124 | - if($timestamp === false) |
|
| 124 | + if ($timestamp === false) |
|
| 125 | 125 | { |
| 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 | - if($value instanceof \Closure) |
|
| 131 | + if ($value instanceof \Closure) |
|
| 132 | 132 | { |
| 133 | 133 | $value = $value($timestamp); |
| 134 | 134 | } |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | public function setAttribute($attributeName, $value) |
| 149 | 149 | { |
| 150 | - if($attributeName !== 'headers') |
|
| 150 | + if ($attributeName !== 'headers') |
|
| 151 | 151 | { |
| 152 | - if(array_key_exists($attributeName, $this->attributes)) |
|
| 152 | + if (array_key_exists($attributeName, $this->attributes)) |
|
| 153 | 153 | { |
| 154 | 154 | $this->attributes[$attributeName] = $value; |
| 155 | 155 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | public function getAttribute($attributeName) |
| 174 | 174 | { |
| 175 | - if(array_key_exists($attributeName, $this->attributes)) |
|
| 175 | + if (array_key_exists($attributeName, $this->attributes)) |
|
| 176 | 176 | { |
| 177 | 177 | return $this->attributes[$attributeName]; |
| 178 | 178 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | { |
| 204 | 204 | $routingKey = $readableMessage->getRoutingKey(); |
| 205 | 205 | |
| 206 | - if($newRoutingKey !== false) |
|
| 206 | + if ($newRoutingKey !== false) |
|
| 207 | 207 | { |
| 208 | 208 | $routingKey = $newRoutingKey; |
| 209 | 209 | } |
@@ -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 | } |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | $attributes = $readableMessage->getAttributes(); |
| 224 | 224 | $skippedAttributes = array('timestamp', 'headers', 'app_id', 'routing_key'); |
| 225 | - foreach($attributes as $attributeName => $value) |
|
| 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 | } |
@@ -23,12 +23,12 @@ discard block |
||
| 23 | 23 | $workerContext = null; |
| 24 | 24 | $key = $this->computeWorkerServiceKey($workerName); |
| 25 | 25 | |
| 26 | - if(isset($this->container[$key])) |
|
| 26 | + if (isset($this->container[$key])) |
|
| 27 | 27 | { |
| 28 | 28 | $workerContext = $this->container[$key]; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if(isset($this->container[self::MESSAGE_HOOKS_DIC_KEY])) |
|
| 31 | + if (isset($this->container[self::MESSAGE_HOOKS_DIC_KEY])) |
|
| 32 | 32 | { |
| 33 | 33 | $workerContext->setMessageHooks($this->container[self::MESSAGE_HOOKS_DIC_KEY]); |
| 34 | 34 | } |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $workers = array(); |
| 66 | 66 | |
| 67 | - foreach($extractedWorkers as $worker) |
|
| 67 | + foreach ($extractedWorkers as $worker) |
|
| 68 | 68 | { |
| 69 | 69 | $key = $this->formatWorkerName($worker); |
| 70 | 70 | $worker = $this->container[$worker]; |
| 71 | 71 | |
| 72 | - if($worker instanceof WorkerContext) |
|
| 72 | + if ($worker instanceof WorkerContext) |
|
| 73 | 73 | { |
| 74 | 74 | $workers[$key] = [ |
| 75 | 75 | 'queue' => $worker->getQueue(), |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function getWorker() |
| 44 | 44 | { |
| 45 | - if($this->worker instanceof \Closure) |
|
| 45 | + if ($this->worker instanceof \Closure) |
|
| 46 | 46 | { |
| 47 | 47 | $closure = $this->worker; |
| 48 | 48 | $this->worker = $closure(); |
@@ -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 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $callable = $this->getFormatterStrategy($this->getContentType()); |
| 51 | 51 | $body = $this->getRawBody(); |
| 52 | 52 | |
| 53 | - if($callable instanceof \Closure) |
|
| 53 | + if ($callable instanceof \Closure) |
|
| 54 | 54 | { |
| 55 | 55 | $body = $callable($body); |
| 56 | 56 | } |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | public function applyHooks(MessageHookCollection $messageHookCollection) |
| 67 | 67 | { |
| 68 | - if(!empty($messageHookCollection)) |
|
| 68 | + if (!empty($messageHookCollection)) |
|
| 69 | 69 | { |
| 70 | - foreach($messageHookCollection as $messageHook) |
|
| 70 | + foreach ($messageHookCollection as $messageHook) |
|
| 71 | 71 | { |
| 72 | - if($messageHook instanceof MessageHook) |
|
| 72 | + if ($messageHook instanceof MessageHook) |
|
| 73 | 73 | { |
| 74 | 74 | $this->decodedBody = $messageHook->process($this->decodedBody); |
| 75 | 75 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | public function getAttribute($attributeName) |
| 86 | 86 | { |
| 87 | 87 | $messageProperties = $this->message->getProperties(); |
| 88 | - if(array_key_exists($attributeName, $messageProperties)) |
|
| 88 | + if (array_key_exists($attributeName, $messageProperties)) |
|
| 89 | 89 | { |
| 90 | 90 | return $messageProperties[$attributeName]; |
| 91 | 91 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | }, |
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | - if(array_key_exists($contentType, $formatterStrategies) === true) |
|
| 104 | + if (array_key_exists($contentType, $formatterStrategies) === true) |
|
| 105 | 105 | { |
| 106 | 106 | return $formatterStrategies[$contentType]; |
| 107 | 107 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | private function getHeader($headerName) |
| 135 | 135 | { |
| 136 | 136 | $headers = $this->getHeaders(); |
| 137 | - if(array_key_exists($headerName, $headers)) |
|
| 137 | + if (array_key_exists($headerName, $headers)) |
|
| 138 | 138 | { |
| 139 | 139 | return $headers[$headerName]; |
| 140 | 140 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 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 @@ discard block |
||
| 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 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $processResult = $this->workerContext->getWorker()->process($message); |
| 40 | 40 | } |
| 41 | - catch(\Exception $exception) |
|
| 41 | + catch (\Exception $exception) |
|
| 42 | 42 | { |
| 43 | 43 | $this->onWorkerProcessed(); |
| 44 | 44 | |
@@ -43,12 +43,12 @@ |
||
| 43 | 43 | 'max_execution_time' => self::DEFAULT_MAX_EXECUTION_TIME, |
| 44 | 44 | ); |
| 45 | 45 | |
| 46 | - if(!empty($this->retries)) |
|
| 46 | + if (!empty($this->retries)) |
|
| 47 | 47 | { |
| 48 | 48 | $options['instant_retry_attempts'] = $this->retries; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if(!empty($this->delay)) |
|
| 51 | + if (!empty($this->delay)) |
|
| 52 | 52 | { |
| 53 | 53 | $options['instant_retry_delay'] = $this->delay * 1000000; //computed in microseconds |
| 54 | 54 | } |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | 'retry_key_pattern' => sprintf(self::RETRY_ROUTING_KEY_PATTERN, $workerContext->queue), |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | - if(! empty($this->retries)) |
|
| 55 | + if (!empty($this->retries)) |
|
| 56 | 56 | { |
| 57 | 57 | $options['retry_attempts'] = $this->retries; |
| 58 | 58 | } |
@@ -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 | } |