Skip to content

Commit

Permalink
Pre-release: updated copyrighted content
Browse files Browse the repository at this point in the history
  • Loading branch information
cclilshy committed Nov 13, 2024
1 parent 700e48b commit a587638
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: 初始化测试路由 (Initialize Test Route)
working-directory: laravel-app
run: |
echo "PRP_HTTP_WORKERS=1" >> .env
echo "RIP_HTTP_WORKERS=1" >> .env
cp ./vendor/cloudtay/ripple-driver/src/Laravel/Tests/routes-test.php routes/test.php
php artisan vendor:publish --tag=ripple-config
php artisan optimize
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/thinkphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: 初始化测试路由 (Initialize Test Route)
working-directory: thinkphp-app
run: |
echo "PRP_HTTP_WORKERS=1" >> .env
echo "RIP_HTTP_WORKERS=1" >> .env
cp ./vendor/cloudtay/ripple-driver/src/ThinkPHP/Tests/routes-test.php route/test.php
- name: 启动引擎服务 (Start Server)
Expand Down
6 changes: 3 additions & 3 deletions src/Laravel/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PRP_HTTP_LISTEN=http://127.0.0.1:8008
PRP_HTTP_WORKERS=4
PRP_HTTP_RELOAD=0
RIP_HTTP_LISTEN=http://127.0.0.1:8008
RIP_HTTP_WORKERS=4
RIP_HTTP_RELOAD=0
6 changes: 3 additions & 3 deletions src/Laravel/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

namespace Ripple\Driver\Laravel;

use Co\IO;
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Config;
Expand All @@ -46,6 +45,7 @@
use Ripple\Driver\Laravel\Traits\DispatchesEvents;
use Ripple\Driver\Utils\Console;
use Ripple\Driver\Utils\Guard;
use Ripple\File\File;
use Ripple\Http\Server;
use Ripple\Http\Server\Request;
use Ripple\Worker\Manager;
Expand All @@ -64,7 +64,7 @@
* @Author cclilshy
* @Date 2024/8/16 23:38
*/
class Worker extends \Ripple\Worker
class Worker extends \Ripple\Worker\Worker
{
use Console;
use DispatchesEvents;
Expand Down Expand Up @@ -126,7 +126,7 @@ public function register(Manager $manager): void
$this->application = Application::getInstance();

if (\Ripple\Driver\Utils\Config::value2bool(Config::get('ripple.HTTP_RELOAD'))) {
$monitor = IO::File()->watch();
$monitor = File::getInstance()->monitor();
$monitor->add(base_path('app'));
$monitor->add(base_path('bootstrap'));
$monitor->add(base_path('config'));
Expand Down
6 changes: 3 additions & 3 deletions src/Laravel/config/ripple.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
use Illuminate\Support\Env;

return [
'HTTP_LISTEN' => Env::get('PRP_HTTP_LISTEN', 'http://127.0.0.1:8008'),
'HTTP_WORKERS' => Env::get('PRP_HTTP_WORKERS', 4),
'HTTP_RELOAD' => Env::get('PRP_HTTP_RELOAD', 0)
'HTTP_LISTEN' => Env::get('RIP_HTTP_LISTEN', 'http://127.0.0.1:8008'),
'HTTP_WORKERS' => Env::get('RIP_HTTP_WORKERS', 4),
'HTTP_RELOAD' => Env::get('RIP_HTTP_RELOAD', 0)
];
8 changes: 4 additions & 4 deletions src/ThinkPHP/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PRP_HTTP_LISTEN=http://127.0.0.1:8008
PRP_HTTP_WORKERS=4
PRP_HTTP_RELOAD=0
PRP_HTTP_SANDBOX=1
RIP_HTTP_LISTEN=http://127.0.0.1:8008
RIP_HTTP_WORKERS=4
RIP_HTTP_RELOAD=0
RIP_HTTP_SANDBOX=1
4 changes: 2 additions & 2 deletions src/ThinkPHP/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ private function start(): void
}
});

$listen = Env::get('PRP_HTTP_LISTEN', 'http://127.0.0.1:8008');
$count = intval(Env::get('PRP_HTTP_WORKERS', 4)) ?? 4;
$listen = Env::get('RIP_HTTP_LISTEN', 'http://127.0.0.1:8008');
$count = intval(Env::get('RIP_HTTP_WORKERS', 4)) ?? 4;
$this->manager->addWorker(new Worker($listen, $count));
$this->manager->run();
}
Expand Down
7 changes: 3 additions & 4 deletions src/ThinkPHP/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

namespace Ripple\Driver\ThinkPHP;

use Co\IO;
use Ripple\Driver\Utils\Config;
use Ripple\Driver\Utils\Console;
use Ripple\Driver\Utils\Guard;
Expand Down Expand Up @@ -69,7 +68,7 @@
* @Author cclilshy
* @Date 2024/8/16 23:38
*/
class Worker extends \Ripple\Worker
class Worker extends \Ripple\Worker\Worker
{
use Console;

Expand Down Expand Up @@ -123,7 +122,7 @@ public function register(Manager $manager): void

// 热重载监听文件改动
if (Config::value2bool(Env::get('PHP_HOT_RELOAD'))) {
$monitor = IO::File()->watch();
$monitor = \Ripple\File\File::getInstance()->monitor();
$monitor->add(root_path() . '/app');
$monitor->add(root_path() . '/config');
$monitor->add(root_path() . '/extend');
Expand Down Expand Up @@ -197,7 +196,7 @@ public function boot(): void

# 根据响应类型处理响应内容
if ($thinkResponse instanceof File) {
$response->setContent(IO::File()->open($thinkResponse->getData(), 'r+'));
$response->setContent(\Ripple\File\File::open($thinkResponse->getData(), 'r+'));
} else {
$response->setContent($thinkResponse->getData());
}
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/Guard.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@

use Ripple\File\Monitor;
use Ripple\Utils\Output;
use Ripple\Worker;
use Ripple\Worker\Worker;
use Ripple\Worker\Manager;

class Guard
{
/**
* @param \Ripple\Worker\Manager $manager
* @param \Ripple\Worker $worker
* @param \Ripple\Worker\Worker $worker
* @param \Ripple\File\Monitor $monitor
*
* @return void
Expand Down
30 changes: 15 additions & 15 deletions src/Workerman/Driver4.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@

use Closure;
use Ripple\Kernel;
use Ripple\Process;
use Ripple\Process\Process;
use Ripple\Stream;
use Ripple\Utils\Format;
use Throwable;
use Workerman\Events\EventInterface;
use Workerman\Worker;
Expand All @@ -56,13 +57,11 @@
use function function_exists;
use function get_resource_id;
use function getmypid;
use function int2string;
use function is_array;
use function is_string;
use function posix_getpid;
use function sleep;
use function str_contains;
use function string2int;

class Driver4 implements EventInterface
{
Expand Down Expand Up @@ -121,8 +120,8 @@ public function add($fd, $flag, $func, $args = []): bool|int
}

$id = onSignal($fd, $closure);
$this->_signal2ids[$fd] = string2int($id);
return string2int($id);
$this->_signal2ids[$fd] = Format::string2int($id);
return Format::string2int($id);
} catch (Throwable) {
return false;
}
Expand All @@ -135,7 +134,7 @@ public function add($fd, $flag, $func, $args = []): bool|int
Worker::stopAll(250, $e);
}
}, $fd);
return string2int($timerId);
return Format::string2int($timerId);

case EventInterface::EV_TIMER_ONCE:
$this->_timer[] = $timerId = delay(function () use ($func, $args) {
Expand All @@ -145,25 +144,25 @@ public function add($fd, $flag, $func, $args = []): bool|int
Worker::stopAll(250, $e);
}
}, $fd);
return string2int($timerId);
return Format::string2int($timerId);

case EventInterface::EV_READ:
$stream = new Stream($fd);
$eventId = $stream->onReadable(function (Stream $stream) use ($func) {
$func($stream->stream);
});

$this->_fd2RIDs[$stream->id][] = string2int($eventId);
return string2int($eventId);
$this->_fd2RIDs[$stream->id][] = Format::string2int($eventId);
return Format::string2int($eventId);

case EventInterface::EV_WRITE:
$stream = new Stream($fd);
$eventId = $stream->onWriteable(function (Stream $stream) use ($func) {
$func($stream->stream);
});

$this->_fd2WIDs[$stream->id][] = string2int($eventId);
return string2int($eventId);
$this->_fd2WIDs[$stream->id][] = Format::string2int($eventId);
return Format::string2int($eventId);
}
return false;
}
Expand All @@ -182,7 +181,7 @@ public function del($fd, $flag): void
if ($flag === EventInterface::EV_TIMER || $flag === EventInterface::EV_TIMER_ONCE) {
// 取消定时器
$this->cancel($fd);
unset($this->_timer[array_search(int2string($fd), $this->_timer)]);
unset($this->_timer[array_search(Format::int2string($fd), $this->_timer)]);
return;
}

Expand All @@ -194,12 +193,12 @@ public function del($fd, $flag): void
$streamId = get_resource_id($fd);
if ($flag === EventInterface::EV_READ) {
foreach ($this->_fd2RIDs[$streamId] ?? [] as $eventId) {
cancel(int2string($eventId));
cancel(Format::int2string($eventId));
}
unset($this->_fd2RIDs[$streamId]);
} else {
foreach ($this->_fd2WIDs[$streamId] ?? [] as $eventId) {
cancel(int2string($eventId));
cancel(Format::int2string($eventId));
}
unset($this->_fd2WIDs[$streamId]);
}
Expand All @@ -225,7 +224,7 @@ public function del($fd, $flag): void
*/
private function cancel(int $id): void
{
cancel(int2string($id));
cancel(Format::int2string($id));
}

/**
Expand Down Expand Up @@ -253,6 +252,7 @@ public function loop(): void
Process::getInstance()->forgetEvents();
});
}

wait();

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Workerman/Driver5.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

use Revolt\EventLoop;
use Ripple\Kernel;
use Ripple\Process;
use Ripple\Process\Process;
use Workerman\Events\EventInterface;

use function array_shift;
Expand Down
6 changes: 3 additions & 3 deletions src/Yii2/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

namespace Ripple\Driver\Yii2;

use Co\IO;
use Ripple\File\File;
use Ripple\Http\Server\Request;
use Ripple\Http\Server;
use Ripple\Driver\Utils\Config;
Expand All @@ -58,7 +58,7 @@
* @Author cclilshy
* @Date 2024/8/16 23:38
*/
class Worker extends \Ripple\Worker
class Worker extends \Ripple\Worker\Worker
{
use Console;

Expand Down Expand Up @@ -135,7 +135,7 @@ public function register(Manager $manager): void
$this->application = new Application($config);

if (Config::value2bool(1)) {
$monitor = IO::File()->watch();
$monitor = File::getInstance()->monitor();
$monitor->add($this->rootPath . ('/commands'));
$monitor->add($this->rootPath . ('/controllers'));
$monitor->add($this->rootPath . ('/mail'));
Expand Down

0 comments on commit a587638

Please sign in to comment.