Skip to content

Commit

Permalink
Project: Update logo and .tarignore
Browse files Browse the repository at this point in the history
  • Loading branch information
cclilshy committed Feb 8, 2025
1 parent b283daf commit 221e4e3
Show file tree
Hide file tree
Showing 12 changed files with 363 additions and 328 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ composer.lock
.php-cs-fixer.cache
.phpunit.cache
.phpunit.result.cache
.cursor
4 changes: 4 additions & 0 deletions .tarignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/assets/
/docs/
/examples/
/tests/
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="https://raw.githubusercontent.com/cloudtay/ripple/refs/heads/main/assets/images/logo.png" width="420" alt="Logo">
<img src="assets/images/logo.png" width="420" alt="Logo">
</p>
<p align="center">
<a href="#"><img src="https://img.shields.io/badge/PHP-%3E%3D%208.1-blue" alt="Build Status"></a>
Expand Down Expand Up @@ -35,19 +35,22 @@ visit [Quick Deployment](https://ripple.cloudtay.com/docs/install/server)
> We allow users to choose applicable component libraries by themselves. All components can be used as described in the
> document without additional configuration.
**🚀 [Guzzle](https://docs.guzzlephp.org/en/stable/)**
**🚀 [Guzzle](https://docs.guzzlephp.org/en/stable/)**
PHP is the most widely used HTTP client

**🔥 [AmPHP](https://amphp.org/)**
**🔥 [AmPHP](https://amphp.org/)**
Provides rich PHP asynchronous components for users to encapsulate by themselves

**🚀 [Driver](https://github.com/cloudtay/ripple-driver)**
**🚀 [Laravel-ripple](https://github.com/cloudtay/laravel-ripple)**
The official high-performance driver library provides seamless access to your traditional applications.

**🚀 [Webman-coroutine](https://github.com/workbunny/webman-coroutine)**
**🚀 [Workerman-ripple](https://github.com/cloudtay/workerman-ripple)**
The official high-performance driver library provides seamless access to your traditional applications.

**🚀 [Webman-coroutine](https://github.com/workbunny/webman-coroutine)**
The workbunny team's integrated webman coroutine extension provides coroutine support for Webman.

**🟢[ripple](https://github.com/cloudtay/ripple)**
**🟢 [ripple](https://github.com/cloudtay/ripple)**
Provides standard coroutine architecture and tools for rapid development or packaging of traditional applications

### Event Library Guide
Expand Down
31 changes: 17 additions & 14 deletions README.zh_cn.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="https://raw.githubusercontent.com/cloudtay/ripple/refs/heads/main/assets/images/logo.png" width="420" alt="Logo">
<img src="assets/images/logo.png" width="420" alt="Logo">
</p>
<p align="center">
<a href="#"><img src="https://img.shields.io/badge/PHP-%3E%3D%208.1-blue" alt="Build Status"></a>
Expand All @@ -18,9 +18,9 @@ ripple是一个现代化的、高性能的原生PHP协程引擎, 旨在解决PHP

**`🎉 加入方式`** 通过以下方式添加作者微信即可加入交流群

| 微信二维码 |
|----------------------------------------------------------------------------------------------------------------------|
| <img src="https://raw.githubusercontent.com/cloudtay/ripple/refs/heads/main/assets/images/wechat.jpg" width="380" /> |
| 微信二维码 |
|----------------------------------------------------|
| <img src="assets/images/wechat.jpg" width="380" /> |

## 安装

Expand All @@ -42,20 +42,23 @@ composer require cloudtay/ripple

> 我们允许用户自行选择适用的组件库, 所有组件只需像文档中描述的方式即可无需额外配置
**🚀 [Guzzle](https://docs.guzzlephp.org/en/stable/)**
PHP应用最为广泛的HTTP客户端
**🚀 [Guzzle]https://docs.guzzlephp.org/en/stable/**
PHP 是使用最广泛的 HTTP 客户端

**🔥 [AmPHP](https://amphp.org/)**
提供丰富的PHP异步组件供用户自行封装
**🔥 [AmPHP]https://amphp.org/**
提供丰富的 PHP 异步组件供用户自行封装

**🚀 [Driver](https://github.com/cloudtay/ripple-driver)**
官方提供的高性能驱动库,无缝接入你的传统应用
**🚀 [Laravel-ripple]https://github.com/cloudtay/laravel-ripple)**
官方高性能驱动程序库提供对传统应用程序的无缝访问。

**🚀 [Webman-coroutine](https://github.com/workbunny/webman-coroutine)**
workbunny团队体统的webman协程扩展, 为Webman提供了协程支持
**🚀 [Workerman-ripple]https://github.com/cloudtay/workerman-ripple)**
官方高性能驱动程序库提供对传统应用程序的无缝访问。

**🟢 [ripple](https://github.com/cloudtay/ripple)**
提供标准的协程架构与工具用于迅速开发或封装传统应用
**🚀 [webman-coroutine]https://github.com/workbunny/webman-coroutine)**
workbunny 团队的集成 webman 协程扩展为 Webman 提供协程支持。

**🟢[ripple]https://github.com/cloudtay/ripple)**
提供标准协程架构和工具,用于快速开发或打包传统应用程序

### 事件库指南

Expand Down
Binary file modified assets/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions example/worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* @return void
*/
protected function boot(): void
public function boot(): void
{
\var_dump($this->getIndex());
\Co\sleep(10);
Expand All @@ -34,7 +34,7 @@ protected function boot(): void
*
* @return void
*/
protected function register(Manager $manager): void
public function register(Manager $manager): void
{
// TODO: Implement register() method.
}
Expand Down Expand Up @@ -64,13 +64,13 @@ protected function onCommand(Command $command): void
/**
* @return void
*/
protected function boot(): void
public function boot(): void
{
\Co\sleep(6);
$this->forwardCommand(Command::make('test'), 'abc', 2);
}

protected function register(Manager $manager): void
public function register(Manager $manager): void
{
// TODO: Implement register() method.
}
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,6 @@ public function getMemorySize(): int
break;
}

return $this->memorySize = 0;
return $this->memorySize = -1;
}
}
51 changes: 25 additions & 26 deletions src/Worker/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Ripple\Utils\Output;
use Ripple\Utils\Serialization\Zx7e;
use BadMethodCallException;
use Throwable;

use function getmypid;
use function posix_getpid;
Expand Down Expand Up @@ -128,12 +129,12 @@ protected function __onCommand(Command $workerCommand, string $name, int $index)
break;

case WorkerContext::COMMAND_SYNC_ID:
if ($stream = $this->workers[$name]?->getStreams()[$index] ?? null) {
if ($workerProcess = $this->workers[$name]?->getWorkerProcess($index)) {
$sync = $this->index++;
$id = $workerCommand->arguments['id'];
$command = Command::make(WorkerContext::COMMAND_SYNC_ID, ['sync' => $sync, 'id' => $id]);
try {
$stream->write($this->zx7e->encodeFrame($command->__toString()));
$workerProcess->command($command);
} catch (ConnectionException $e) {
Output::warning($e->getMessage());
}
Expand Down Expand Up @@ -183,35 +184,22 @@ public function reload(string|null $name = null): void
public function sendCommand(Command $command, string|null $name = null, int|null $index = null): void
{
if ($name) {
if (isset($this->workers[$name])) {
if ($index) {
if ($stream = $this->workers[$name]?->getStreams()[$index] ?? null) {
try {
$stream->write($this->zx7e->encodeFrame($command->__toString()));
} catch (ConnectionException $e) {
Output::warning($e->getMessage());
}
}
return;
}
foreach ($this->workers[$name]->getStreams() as $stream) {
try {
$stream->write($this->zx7e->encodeFrame($command->__toString()));
} catch (ConnectionException $e) {
Output::warning($e->getMessage());
}
if (!$worker = $this->workers[$name] ?? null) {
return;
}

$workerProcesses = $index ? [$worker->getWorkerProcess($index)] : $worker->getWorkerProcess();
foreach ($workerProcesses as $workerProcess) {
try {
$workerProcess?->command($command);
} catch (ConnectionException $e) {
Output::warning($e->getMessage());
}
}
} else {
$workers = $this->workers;
foreach ($workers as $worker) {
foreach ($worker->getStreams() as $stream) {
try {
$stream->write($this->zx7e->encodeFrame($command->__toString()));
} catch (ConnectionException $e) {
Output::warning($e->getMessage());
}
}
$this->sendCommand($command, $worker->getName());
}
}
}
Expand All @@ -229,7 +217,18 @@ public function run(): bool
} else {
$this->processID = posix_getpid();
}

$this->zx7e = new Zx7e();
foreach ($this->workers as $worker) {
try {
$worker->register($this);
} catch (Throwable $exception) {
Output::error("Worker {$worker->getName()} registration failed: {$exception->getMessage()}, will be removed");
$this->remove($worker->getName());
return false;
}
}

foreach ($this->workers as $worker) {
if (!$worker->run($this)) {
Output::error("worker {$worker->getName()} failed to start");
Expand Down
Loading

0 comments on commit 221e4e3

Please sign in to comment.