-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from tegbessou/add-mongodb-check
Adding a check for mongodb connection
- Loading branch information
Showing
7 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Liip\MonitorBundle\Check; | ||
|
||
use Doctrine\Bundle\MongoDBBundle\ManagerRegistry; | ||
use ZendDiagnostics\Check\AbstractCheck; | ||
use ZendDiagnostics\Result\Success; | ||
|
||
class DoctrineMongoDb extends AbstractCheck | ||
{ | ||
protected $manager; | ||
protected $connectionName; | ||
|
||
public function __construct(ManagerRegistry $registry, $connectionName = null) | ||
{ | ||
$this->manager = $registry; | ||
$this->connectionName = $connectionName; | ||
} | ||
|
||
public function check() | ||
{ | ||
$connection = $this->manager->getConnection(); | ||
$connection->connect(); | ||
|
||
return new Success(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Liip\MonitorBundle\Check; | ||
|
||
use Doctrine\Common\Persistence\ConnectionRegistry; | ||
use ZendDiagnostics\Check\CheckCollectionInterface; | ||
|
||
/** | ||
* @author Hugues Gobet <[email protected]> | ||
*/ | ||
class DoctrineMongoDbCollection implements CheckCollectionInterface | ||
{ | ||
private $checks = array(); | ||
|
||
public function __construct(ConnectionRegistry $manager, $connections) | ||
{ | ||
if (!is_array($connections)) { | ||
$connections = array($connections); | ||
} | ||
|
||
foreach ($connections as $connection) { | ||
$check = new DoctrineMongoDb($manager, $connection); | ||
$check->setLabel(sprintf('Doctrine Mongo Db "%s" connection', $connection)); | ||
|
||
$this->checks[sprintf('doctrine_dbal_%s_connection', $connection)] = $check; | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getChecks() | ||
{ | ||
return $this->checks; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<parameters> | ||
<parameter key="liip_monitor.check.doctrine_mongodb.class">Liip\MonitorBundle\Check\DoctrineMongoDbCollection</parameter> | ||
</parameters> | ||
|
||
<services> | ||
<service id="liip_monitor.check.doctrine_mongodb" public="false" class="%liip_monitor.check.doctrine_mongodb.class%"> | ||
<argument type="service" id="doctrine_mongodb" /> | ||
<argument>%%liip_monitor.check.doctrine_mongodb%%</argument> | ||
<tag name="liip_monitor.check_collection" /> | ||
</service> | ||
</services> | ||
</container> |