All Projects → leocavalcante → swoole-postgresql-doctrine-driver

leocavalcante / swoole-postgresql-doctrine-driver

Licence: MIT license
🔌 A Doctrine DBAL Driver implementation on top of Swoole Coroutine PostgreSQL client

Programming Languages

PHP
23972 projects - #3 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to swoole-postgresql-doctrine-driver

Ycsocket
基于swoole的socket框架,支持协程版MySQL、Redis连接池,已用于大型RPG游戏服务端
Stars: ✭ 77 (+413.33%)
Mutual labels:  pool, swoole, coroutine
Smproxy
Swoole MySQL Proxy 一个基于 MySQL 协议,Swoole 开发的MySQL数据库连接池。 A MySQL database connection pool based on MySQL protocol and Swoole.
Stars: ✭ 1,665 (+11000%)
Mutual labels:  pool, swoole, connection-pool
Groupco
PHP的服务化框架。适用于Api、Http Server、Rpc Server;帮助原生PHP项目转向微服务化。出色的性能与支持高并发的协程相结合
Stars: ✭ 473 (+3053.33%)
Mutual labels:  pool, swoole
Pool
General Purpose Connection Pool for GRPC,RPC,TCP Sevice Cluster
Stars: ✭ 98 (+553.33%)
Mutual labels:  pool, connection-pool
Mobc
A generic connection pool for Rust with async/await support
Stars: ✭ 141 (+840%)
Mutual labels:  pool, connection-pool
Yurunhttp
YurunHttp 是开源的 PHP HTTP 客户端,支持链式操作,简单易用。完美支持Curl、Swoole 协程。QQ群:17916227
Stars: ✭ 197 (+1213.33%)
Mutual labels:  swoole, coroutine
Stormpot
A fast object pool for the JVM
Stars: ✭ 267 (+1680%)
Mutual labels:  pool, connection-pool
Guzzle Swoole
让基于 Guzzle 的项目完美无缝兼容 Swoole 协程,支持:Guzzle、Elasticsearch client——来自宇润 PHP 全家桶
Stars: ✭ 143 (+853.33%)
Mutual labels:  swoole, coroutine
event-sourcing
A lightweight but also all-inclusive event sourcing library with a focus on developer experience and based on doctrine dbal
Stars: ✭ 65 (+333.33%)
Mutual labels:  dbal, doctrine
petstore
A simple skeleton to build api's based on the chubbyphp-framework, mezzio (former zend-expressive) or slim.
Stars: ✭ 34 (+126.67%)
Mutual labels:  dbal, doctrine
pool
Go library that wraps http.Client to provide seamless higher-level connection pooling features
Stars: ✭ 39 (+160%)
Mutual labels:  pool, connection-pool
Connection Pool
A common connection pool based on Swoole is usually used as a database connection pool.
Stars: ✭ 164 (+993.33%)
Mutual labels:  swoole, connection-pool
Hyperf Skeleton
🛠 A skeleton of Hyperf framework that provided by official team
Stars: ✭ 162 (+980%)
Mutual labels:  swoole, coroutine
Libcopp
cross-platform coroutine library in c++
Stars: ✭ 398 (+2553.33%)
Mutual labels:  pool, coroutine
Yii2 Swoole
make yii2 project runing on swoole
Stars: ✭ 161 (+973.33%)
Mutual labels:  swoole, coroutine
vertica-swoole-adapter
Provides a DB layer for Swoole-based applications to communicate to HP Vertica databases.
Stars: ✭ 14 (-6.67%)
Mutual labels:  swoole, connection-pool
Swoole Docker
See: https://github.com/swoole/docker-swoole
Stars: ✭ 132 (+780%)
Mutual labels:  swoole, coroutine
Aint Queue
🚀 An async-queue library built on top of swoole, flexable multi-consumer, coroutine supported. 基于 Swoole 的一个异步队列库,可弹性伸缩的工作进程池,工作进程协程支持。
Stars: ✭ 143 (+853.33%)
Mutual labels:  swoole, coroutine
Swoft Im
基于swoft-cloud的微服务架构,最小化拆分粒度,PHP7、多进程、协程、异步任务、mysql连接池、redi连接池、rpc连接池、服务治理、服务注册与发现、Aop切面、全注解
Stars: ✭ 189 (+1160%)
Mutual labels:  pool, swoole
ext-postgresql
🐘 Coroutine-based client for PostgreSQL
Stars: ✭ 62 (+313.33%)
Mutual labels:  swoole, coroutine

Swoole Coroutine PostgreSQL Doctrine DBAL Driver

A Doctrine\DBAL\Driver implementation on top of Swoole\Coroutine\PostgreSQL.

Getting started

Install

composer require leocavalcante/swoole-postgresql-doctrine-driver

Usage

Doctrine parameters, for both DBAL and ORM projects, accepts the driverClass option; it is where we can inject this project's driver:

use Doctrine\DBAL\{Driver, DriverManager};

$params = [
    'dbname' => 'postgres',
    'user' => 'postgres',
    'password' => 'postgres',
    'host' => 'db',
    'driverClass' => Driver\Swoole\Coroutine\PostgreSQL\Driver::class,
    'poolSize' => 8,
];

$conn = DriverManager::getConnection($params);

Yes, I deliberately used the Doctrine\DBAL\Driver namespace + Swoole\Coroutine\PostgreSQL namespace, so it is not confusing.

You are ready to rock inside Coroutines (Fibers):

Co\run(static function() use ($conn): void {
    $results = [];
    $wg = new Co\WaitGroup();
    $start_time = time();

    Co::create(static function() use (&$results, $wg, $conn): void {
        $wg->add();
        $results[] = $conn->executeQuery('select 1, pg_sleep(1)')->fetchOne();
        $wg->done();
    });

    Co::create(static function() use (&$results, $wg, $conn): void {
        $wg->add();
        $results[] = $conn->executeQuery('select 1, pg_sleep(1)')->fetchOne();
        $wg->done();
    });

    $wg->wait();
    $elapsed = time() - $start_time;
    $sum = array_sum($results);

    echo "Two pg_sleep(1) queries in $elapsed second, returning: $sum\n";
});

You should be seeing Two pg_sleep(1) queries in 1 second, returning: 2 and the total time should not be 2 (the sum of pg_sleep(1)'s) because they ran concurrently.

real    0m1.228s
user    0m0.036s
sys     0m0.027s

Developing

Use Composer through Docker

docker-compose run --rm composer install
docker-compose run --rm composer test

It will build a development image with PHP, Swoole, Swoole's PostgreSQL extension and PCOV for coverage.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].