@@ -11,17 +11,17 @@ |
||
11 | 11 | public function boot() |
12 | 12 | { |
13 | 13 | $this->publishes([ |
14 | - __DIR__ . '/../../../config/prometheus.php' => base_path('config/prometheus.php'), |
|
14 | + __DIR__.'/../../../config/prometheus.php' => base_path('config/prometheus.php'), |
|
15 | 15 | ]); |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function register() |
19 | 19 | { |
20 | 20 | $this->mergeConfigFrom( |
21 | - __DIR__ . '/../../../config/prometheus.php', 'prometheus' |
|
21 | + __DIR__.'/../../../config/prometheus.php', 'prometheus' |
|
22 | 22 | ); |
23 | 23 | |
24 | - $this->app->singleton(PrometheusExporter::class, function ($app) { |
|
24 | + $this->app->singleton(PrometheusExporter::class, function($app) { |
|
25 | 25 | return new PrometheusExporter($app['config']->get('prometheus')); |
26 | 26 | }); |
27 | 27 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | 'value' => $apcSmaInfo['avail_mem'], |
156 | 156 | ], |
157 | 157 | ]; |
158 | - foreach (new \APCuIterator('/^' . $this->config['apcu_key_prefix'] . $this->config['apcu_key_separator'] . '/') as $item) { |
|
158 | + foreach (new \APCuIterator('/^'.$this->config['apcu_key_prefix'].$this->config['apcu_key_separator'].'/') as $item) { |
|
159 | 159 | $value = apcu_fetch($item['key'], $success); |
160 | 160 | if (!$success) { |
161 | 161 | continue; |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | $metrics = array_merge($this->getSystemLoadAvgMetrics(), $this->getSwooleMetrics(), $this->getApcuMetrics()); |
182 | 182 | $lines = []; |
183 | 183 | foreach ($metrics as $metric) { |
184 | - $lines[] = "# HELP " . $metric['name'] . " {$metric['help']}"; |
|
185 | - $lines[] = "# TYPE " . $metric['name'] . " {$metric['type']}"; |
|
184 | + $lines[] = "# HELP ".$metric['name']." {$metric['help']}"; |
|
185 | + $lines[] = "# TYPE ".$metric['name']." {$metric['type']}"; |
|
186 | 186 | |
187 | 187 | $metricLabels = isset($metric['labels']) ? $metric['labels'] : []; |
188 | 188 | $labels = ['{']; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | } |
194 | 194 | $labels[] = '}'; |
195 | 195 | $labelStr = implode('', $labels); |
196 | - $lines[] = $metric['name'] . "$labelStr {$metric['value']}"; |
|
196 | + $lines[] = $metric['name']."$labelStr {$metric['value']}"; |
|
197 | 197 | } |
198 | 198 | return implode("\n", $lines); |
199 | 199 | } |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | $this->clientIp = current(swoole_get_local_ip()) ?: gethostname(); |
42 | 42 | } |
43 | 43 | if (isset($settings['pull_timeout'])) { |
44 | - $this->pullTimeout = (int)$settings['pull_timeout']; |
|
44 | + $this->pullTimeout = (int) $settings['pull_timeout']; |
|
45 | 45 | } |
46 | 46 | if (isset($settings['backup_old_env'])) { |
47 | - $this->backupOldEnv = (bool)$settings['backup_old_env']; |
|
47 | + $this->backupOldEnv = (bool) $settings['backup_old_env']; |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | $settings = [ |
74 | 74 | 'server' => getenv('APOLLO_SERVER'), |
75 | 75 | 'app_id' => getenv('APOLLO_APP_ID'), |
76 | - 'cluster' => ($cluster = (string)getenv('APOLLO_CLUSTER')) !== '' ? $cluster : null, |
|
77 | - 'namespaces' => ($namespaces = (string)getenv('APOLLO_NAMESPACES')) !== '' ? explode(',', $namespaces) : null, |
|
78 | - 'client_ip' => ($clientIp = (string)getenv('APOLLO_CLIENT_IP')) !== '' ? $clientIp : null, |
|
79 | - 'pull_timeout' => ($pullTimeout = (int)getenv('APOLLO_PULL_TIMEOUT')) > 0 ? $pullTimeout : null, |
|
80 | - 'backup_old_env' => ($backupOldEnv = (bool)getenv('APOLLO_BACKUP_OLD_ENV')) ? $backupOldEnv : null, |
|
76 | + 'cluster' => ($cluster = (string) getenv('APOLLO_CLUSTER')) !== '' ? $cluster : null, |
|
77 | + 'namespaces' => ($namespaces = (string) getenv('APOLLO_NAMESPACES')) !== '' ? explode(',', $namespaces) : null, |
|
78 | + 'client_ip' => ($clientIp = (string) getenv('APOLLO_CLIENT_IP')) !== '' ? $clientIp : null, |
|
79 | + 'pull_timeout' => ($pullTimeout = (int) getenv('APOLLO_PULL_TIMEOUT')) > 0 ? $pullTimeout : null, |
|
80 | + 'backup_old_env' => ($backupOldEnv = (bool) getenv('APOLLO_BACKUP_OLD_ENV')) ? $backupOldEnv : null, |
|
81 | 81 | ]; |
82 | 82 | return new static($settings); |
83 | 83 | } |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | 'cluster' => isset($options['apollo-cluster']) && $options['apollo-cluster'] !== '' ? $options['apollo-cluster'] : null, |
94 | 94 | 'namespaces' => !empty($options['apollo-namespaces']) ? $options['apollo-namespaces'] : null, |
95 | 95 | 'client_ip' => isset($options['apollo-client-ip']) && $options['apollo-client-ip'] !== '' ? $options['apollo-client-ip'] : null, |
96 | - 'pull_timeout' => isset($options['apollo-pull-timeout']) ? (int)$options['apollo-pull-timeout'] : null, |
|
97 | - 'backup_old_env' => isset($options['apollo-backup-old-env']) ? (bool)$options['apollo-backup-old-env'] : null, |
|
96 | + 'pull_timeout' => isset($options['apollo-pull-timeout']) ? (int) $options['apollo-pull-timeout'] : null, |
|
97 | + 'backup_old_env' => isset($options['apollo-backup-old-env']) ? (bool) $options['apollo-backup-old-env'] : null, |
|
98 | 98 | ]; |
99 | 99 | return new static($settings); |
100 | 100 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $configs = []; |
117 | 117 | $uri = sprintf('%s/configs/%s/%s/', $this->server, $this->appId, $this->cluster); |
118 | 118 | foreach ($namespaces as $namespace) { |
119 | - $url = $uri . $namespace . '?' . http_build_query([ |
|
119 | + $url = $uri.$namespace.'?'.http_build_query([ |
|
120 | 120 | 'releaseKey' => $withReleaseKey && isset($this->releaseKeys[$namespace]) ? $this->releaseKeys[$namespace] : null, |
121 | 121 | 'ip' => $this->clientIp, |
122 | 122 | ]); |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | $all = $this->pullAll(false, $options); |
147 | 147 | if (count($all) !== count($this->namespaces)) { |
148 | 148 | $lackNamespaces = array_diff($this->namespaces, array_keys($all)); |
149 | - throw new \RuntimeException('Missing Apollo configurations for namespaces ' . implode(',', $lackNamespaces)); |
|
149 | + throw new \RuntimeException('Missing Apollo configurations for namespaces '.implode(',', $lackNamespaces)); |
|
150 | 150 | } |
151 | 151 | $configs = []; |
152 | 152 | foreach ($all as $namespace => $config) { |
153 | - $configs[] = '# Namespace: ' . $config['namespaceName']; |
|
153 | + $configs[] = '# Namespace: '.$config['namespaceName']; |
|
154 | 154 | ksort($config['configurations']); |
155 | 155 | foreach ($config['configurations'] as $key => $value) { |
156 | 156 | $configs[] = sprintf('%s=%s', $key, $value); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | throw new \RuntimeException('Empty Apollo configuration list'); |
161 | 161 | } |
162 | 162 | if ($this->backupOldEnv && file_exists($filepath)) { |
163 | - rename($filepath, $filepath . '.' . date('YmdHis')); |
|
163 | + rename($filepath, $filepath.'.'.date('YmdHis')); |
|
164 | 164 | } |
165 | 165 | $fileContent = implode(PHP_EOL, $configs); |
166 | 166 | if (Context::inCoroutine()) { |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | if (!empty($this->notifications) && current($this->notifications)['notificationId'] !== -1) { // Ignore the first pull |
201 | 201 | $callback($notifications); |
202 | 202 | } |
203 | - array_walk($notifications, function (&$notification) { |
|
203 | + array_walk($notifications, function(&$notification) { |
|
204 | 204 | unset($notification['messages']); |
205 | 205 | }); |
206 | 206 | $this->notifications = array_merge($this->notifications, array_column($notifications, null, 'namespaceName')); |