Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #76 from meonkeys/master

complete retry support for Loggable* wrappers
  • Loading branch information...
commit 9ac0ba4f96ea50d20de940b9147ee68b308ea356 2 parents 807f9cc + d3b1b4a
@jmikola jmikola authored
View
7 lib/Doctrine/MongoDB/LoggableCollection.php
@@ -51,14 +51,15 @@ class LoggableCollection extends Collection implements Loggable
* @param EventManager $evm The EventManager instance.
* @param string $cmd Mongo cmd character.
* @param Closure $loggerCallable The logger callable.
+ * @param boolean|integer $numRetries Number of times to retry queries.
*/
- public function __construct(Connection $connection, $name, Database $database, EventManager $evm, $cmd, $loggerCallable)
+ public function __construct(Connection $connection, $name, Database $database, EventManager $evm, $cmd, $loggerCallable, $numRetries = 0)
{
if ( ! is_callable($loggerCallable)) {
throw new \InvalidArgumentException('$loggerCallable must be a valid callback');
}
$this->loggerCallable = $loggerCallable;
- parent::__construct($connection, $name, $database, $evm, $cmd);
+ parent::__construct($connection, $name, $database, $evm, $cmd, $numRetries);
}
/**
@@ -253,6 +254,6 @@ public function validate($scanData = false)
/** @override */
protected function wrapCursor(\MongoCursor $cursor, $query, $fields)
{
- return new LoggableCursor($this->connection, $this, $cursor, $this->loggerCallable, $query, $fields);
+ return new LoggableCursor($this->connection, $this, $cursor, $this->loggerCallable, $query, $fields, $this->numRetries);
}
}
View
5 lib/Doctrine/MongoDB/LoggableCursor.php
@@ -59,13 +59,14 @@ class LoggableCursor extends Cursor implements Loggable
* @param mixed $loggerCallable Logger callable.
* @param array $query The query array that was used to create this cursor.
* @param array $query The fields selected on this cursor.
+ * @param boolean|integer $numRetries Number of times to retry queries.
*/
- public function __construct(Connection $connection, Collection $collection, \MongoCursor $mongoCursor, $loggerCallable, array $query, array $fields)
+ public function __construct(Connection $connection, Collection $collection, \MongoCursor $mongoCursor, $loggerCallable, array $query, array $fields, $numRetries = 0)
{
if ( ! is_callable($loggerCallable)) {
throw new \InvalidArgumentException('$loggerCallable must be a valid callback');
}
- parent::__construct($connection, $collection, $mongoCursor);
+ parent::__construct($connection, $collection, $mongoCursor, $query, $fields, $numRetries);
$this->loggerCallable = $loggerCallable;
$this->query = $query;
$this->fields = $fields;
View
2  lib/Doctrine/MongoDB/LoggableDatabase.php
@@ -153,7 +153,7 @@ public function getDBRef(array $ref)
protected function doSelectCollection($name)
{
return new LoggableCollection(
- $this->connection, $name, $this, $this->eventManager, $this->cmd, $this->loggerCallable
+ $this->connection, $name, $this, $this->eventManager, $this->cmd, $this->loggerCallable, $this->numRetries
);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.