32 public static function initPooling(&$config, $offset =
null,
int $size = 16) {
34 $wrapperClass = $dbConfig [
'wrapper'] ?? \Ubiquity\db\providers\pdo\PDOWrapper::class;
35 if (\method_exists ( $wrapperClass,
'getPoolClass' )) {
36 $poolClass = \call_user_func ( $wrapperClass .
'::getPoolClass' );
37 if (\class_exists ( $poolClass,
true )) {
38 $reflection_class = new \ReflectionClass ( $poolClass );
39 self::$pool = $reflection_class->newInstanceArgs ( [ &$config,$offset,$size ] );
41 throw new DAOException ( $poolClass .
' class does not exists!' );
44 throw new DAOException ( $wrapperClass .
' does not support connection pooling!' );
66 public static function go($asyncCallable, $offset =
'default') {
67 $vars = \get_defined_vars ();
68 \Swoole\Coroutine::create (
function () use ($vars, $asyncCallable, $offset) {
70 \call_user_func_array ( $asyncCallable, $vars );