function retry(*Closure $retry*, $numRetries = 1)
{
if ($numRetries < 1) {
return *$retry()*;
}
for ($i = 0; $i <= $numRetries; $i++) {
try {
return *$retry()*;
} catch (MongoDB\Driver\Exception $e) {
if ($i === $numRetries) {
throw $e;
}
}
}
}