Skip to content

Commit

Permalink
Update: Compatibility testing for libev extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
cclilshy committed Aug 27, 2024
1 parent d9a6fbf commit 72309da
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: posix,sockets,pcntl,openssl,parallel,curl
extensions: posix,sockets,pcntl,openssl,parallel,curl,ev
env:
phpts: ts

Expand Down
15 changes: 15 additions & 0 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ By using PRipple, you will experience the advantages of managing tasks from a gl
composer require cclilshy/p-ripple-core
````

### Event Selection Guide

| Extension Types | Recommended Use | Compatibility | Description |
|:---------------:|:---------------:|:-------------:|:------------------------------------------------------------------------------------------------------------------------------------:|
| `libev` | 🟢 | 🟢️ | Event extension `Ev` is a more efficient event extension that performs consistently in various systems and is recommended to be used |
| `Native` || 🟢 | Support pure PHP without extensions |
| `event` | | 🌗 | The event characteristics under different systems are not uniform, and its use is not recommended |
| `swoole` | || Incompatible with multi-threading model, not recommended, but can coexist with PRipple |

### Ev extension installation

```bash
pecl install ev
```

### Learning

You can visit PRipple’s [Documentation](https://p-ripple.cloudtay.com/) to start reading
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ PRipple是一个现代化的、高性能的原生PHP协程引擎,旨在解决P
composer require cclilshy/p-ripple-core
````

### 事件选型指南

| 扩展类型 | 推荐使用 | 兼容性 | 说明 |
|:--------:|:----:|:---:|:---------------------------------:|
| `libev` | 🟢 | 🟢️ | 事件扩展`Ev`是更加高效的事件扩展,在各系统中表现一致,推荐使用 |
| `原生` || 🟢 | 支持纯PHP无扩展使用 |
| `event` | | 🌗 | 在不同系统下的事件特性不统一,不推荐使用 |
| `swoole` | || 与多线程模型不兼容,不推荐使用,但可以与PRipple并存 |

### Ev扩展安装

```bash
pecl install ev
```

### 开始学习

你可以访问PRipple的[文档](https://p-ripple.cloudtay.com/)开始阅读
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Http/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use Psc\Core\Http\Server\HttpServer;
use Psc\Core\LibraryAbstract;
use Psc\Plugins\Guzzle\Guzzle;
use Throwable;

/**
* @Author cclilshy
Expand All @@ -62,6 +63,7 @@ public function Guzzle(): Guzzle
* @param string $address
* @param mixed $context
* @return HttpServer
* @throws Throwable
*/
public function server(string $address, mixed $context = null): HttpServer
{
Expand Down
3 changes: 2 additions & 1 deletion src/Core/Http/Server/HttpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class HttpServer
/**
* @param string $address
* @param mixed|null $context
* @throws Throwable
*/
public function __construct(string $address, mixed $context = null)
{
Expand Down Expand Up @@ -111,7 +112,7 @@ public function __construct(string $address, mixed $context = null)
$this->server->setOption(SOL_SOCKET, SO_REUSEPORT, 1);
$this->server->setOption(SOL_SOCKET, SO_KEEPALIVE, 1);
$this->server->setBlocking(false);
});
})->await();
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Core/WebSocket/Server/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class Server
* @param string $address
* @param mixed|null $context
* @param Options|null $options
* @throws Throwable
*/
public function __construct(string $address, mixed $context = null, Options $options = null)
{
Expand All @@ -112,7 +113,7 @@ public function __construct(string $address, mixed $context = null, Options $opt
$this->server->setOption(SOL_SOCKET, SO_REUSEPORT, 1);
$this->server->setOption(SOL_SOCKET, SO_KEEPALIVE, 1);
$this->server->setBlocking(false);
});
})->await();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Core/WebSocket/WebSocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use Psc\Core\LibraryAbstract;
use Psc\Core\WebSocket\Client\Connection;
use Psc\Core\WebSocket\Server\Server;
use Throwable;

/**
* @Author cclilshy
Expand Down Expand Up @@ -65,6 +66,7 @@ public function connect(string $address, int|float $timeout = 10, mixed $context
* @param mixed $context
* @param Options|null $options
* @return Server
* @throws Throwable
*/
public function server(string $address, mixed $context, Options $options = null): Server
{
Expand Down

0 comments on commit 72309da

Please sign in to comment.