client = $client; } public function testConnection(): bool { try { $this->client->listDatabases(); return true; } catch (Exception $e) { Log::error($e); return false; } } public function doesDatabaseExist(string $database): bool { $this->database = $this->client->selectDB($database); return (bool) $this->database->exists(); } public function createDatabase(string $database): bool { try { $this->database->create( new RetentionPolicy( 'speedtest_retention_policy', config('services.influxdb.retention'), 1, true ) ); return true; } catch (Exception $e) { Log::error($e); return false; } } public function store(Speedtest $speedtest): bool { return $this->database->writePoints([ new Point( 'speedtest', null, ['host' => config('services.influxdb.host')], $speedtest->formatForInfluxDB(), ) ]); } }