改名
This commit is contained in:
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Snowflake\Pool;
|
namespace Snowflake\Pool;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
use Exception;
|
use Exception;
|
||||||
use HttpServer\Http\Context;
|
use HttpServer\Http\Context;
|
||||||
use PDO;
|
use PDO;
|
||||||
@@ -46,6 +47,8 @@ class Connection extends Component
|
|||||||
if (!Context::hasContext('begin_' . $coroutineName)) {
|
if (!Context::hasContext('begin_' . $coroutineName)) {
|
||||||
Context::setContext('begin_' . $coroutineName, 0);
|
Context::setContext('begin_' . $coroutineName, 0);
|
||||||
}
|
}
|
||||||
|
Context::increment('begin_' . $coroutineName, 1);
|
||||||
|
|
||||||
$connection = Context::getContext($coroutineName);
|
$connection = Context::getContext($coroutineName);
|
||||||
if ($connection instanceof PDO && !$connection->inTransaction()) {
|
if ($connection instanceof PDO && !$connection->inTransaction()) {
|
||||||
$connection->beginTransaction();
|
$connection->beginTransaction();
|
||||||
@@ -90,7 +93,7 @@ class Connection extends Component
|
|||||||
/**
|
/**
|
||||||
* @param mixed $config
|
* @param mixed $config
|
||||||
* @param bool $isMaster
|
* @param bool $isMaster
|
||||||
* @return mixed
|
* @return PDO|null
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function get(mixed $config, bool $isMaster = false): ?PDO
|
public function get(mixed $config, bool $isMaster = false): ?PDO
|
||||||
@@ -111,9 +114,9 @@ class Connection extends Component
|
|||||||
/**
|
/**
|
||||||
* @param $coroutineName
|
* @param $coroutineName
|
||||||
* @param $config
|
* @param $config
|
||||||
* @return \Closure
|
* @return Closure
|
||||||
*/
|
*/
|
||||||
public function create($coroutineName, $config)
|
public function create($coroutineName, $config): Closure
|
||||||
{
|
{
|
||||||
return static function () use ($coroutineName, $config) {
|
return static function () use ($coroutineName, $config) {
|
||||||
if (Coroutine::getCid() === -1) {
|
if (Coroutine::getCid() === -1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user