Skip to content

Commit

Permalink
Added threadCount to connection
Browse files Browse the repository at this point in the history
  • Loading branch information
LaravelFreelancerNL committed Nov 24, 2024
1 parent e248271 commit f77f8b9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,18 @@ protected function getElapsedTime($start)
{
return round((microtime(true) - $start) * 1000, 2);
}

/**
* Get the number of open connections for the database.
*
* @return int|null
*/
public function threadCount()
{
if (!$this->arangoClient) {
return null;
}

return $this->arangoClient->monitor()->getCurrentConnections();
}
}
8 changes: 8 additions & 0 deletions tests/Database/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,11 @@
//
// Schema::hasTable('dummy');
//})->throws(QueryException::class);


test('threadCount', function () {
$connection = $this->connection;

expect($connection->threadCount())->toBeInt();
expect($connection->threadCount())->toBeGreaterThan(-1);
});

0 comments on commit f77f8b9

Please sign in to comment.