umbrellio /
php-table-sync
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | namespace Umbrellio\TableSync\Integration\Laravel; |
||||
| 6 | |||||
| 7 | use Illuminate\Log\LogManager; |
||||
| 8 | use Illuminate\Support\ServiceProvider; |
||||
| 9 | use InfluxDB\Client as InfluxClient; |
||||
| 10 | use InfluxDB\Client\Exception as ClientException; |
||||
| 11 | use InfluxDB\Database as InfluxDB; |
||||
| 12 | use InfluxDB\Driver\UDP; |
||||
| 13 | |||||
| 14 | class InfluxDBServiceProvider extends ServiceProvider |
||||
| 15 | { |
||||
| 16 | protected $defer = true; |
||||
| 17 | |||||
| 18 | public function boot() |
||||
| 19 | { |
||||
| 20 | $this->publishes([ |
||||
| 21 | $this->influxdbConfigPath() => config_path('influxdb.php'), |
||||
| 22 | $this->telegrafConfigPath() => config_path('telegraf.php'), |
||||
| 23 | ]); |
||||
| 24 | |||||
| 25 | $this->mergeConfigFrom($this->influxdbConfigPath(), 'influxdb'); |
||||
| 26 | $this->mergeConfigFrom($this->telegrafConfigPath(), 'telegraf'); |
||||
| 27 | |||||
| 28 | if (($logManager = $this->app->make('log')) instanceof LogManager) { |
||||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||||
| 29 | $logManager->extend('influxdb', function ($app, array $config) { |
||||
| 30 | return (new InfluxDBLogChannel($app))($config); |
||||
| 31 | }); |
||||
| 32 | |||||
| 33 | $logManager->extend('telegraf', function ($app, array $config) { |
||||
| 34 | return (new TelegrafLogChannel($app))($config); |
||||
| 35 | }); |
||||
| 36 | } |
||||
| 37 | } |
||||
| 38 | |||||
| 39 | public function register() |
||||
| 40 | { |
||||
| 41 | $this->app->singleton(InfluxDB::class, function ($app) { |
||||
|
0 ignored issues
–
show
The parameter
$app is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 42 | try { |
||||
| 43 | $client = new InfluxClient( |
||||
| 44 | config('influxdb.host'), |
||||
| 45 | config('influxdb.port'), |
||||
| 46 | config('influxdb.username'), |
||||
| 47 | config('influxdb.password'), |
||||
| 48 | config('influxdb.ssl'), |
||||
| 49 | config('influxdb.verifySSL'), |
||||
| 50 | config('influxdb.timeout') |
||||
| 51 | ); |
||||
| 52 | if (config('influxdb.udp.enabled') === true) { |
||||
| 53 | $client->setDriver(new UDP($client->getHost(), config('influxdb.udp.port'))); |
||||
| 54 | } |
||||
| 55 | |||||
| 56 | return $client->selectDB(config('influxdb.dbname')); |
||||
| 57 | } catch (ClientException $clientException) { |
||||
| 58 | return null; |
||||
| 59 | } |
||||
| 60 | }); |
||||
| 61 | } |
||||
| 62 | |||||
| 63 | public function provides(): array |
||||
| 64 | { |
||||
| 65 | return [InfluxDB::class]; |
||||
| 66 | } |
||||
| 67 | |||||
| 68 | protected function influxdbConfigPath(): string |
||||
| 69 | { |
||||
| 70 | return __DIR__ . '/config/influxdb.php'; |
||||
| 71 | } |
||||
| 72 | |||||
| 73 | protected function telegrafConfigPath(): string |
||||
| 74 | { |
||||
| 75 | return __DIR__ . '/config/telegraf.php'; |
||||
| 76 | } |
||||
| 77 | } |
||||
| 78 |