This commit is contained in:
2021-04-28 12:08:10 +08:00
parent 66dfa660d5
commit 872e1a4ea0
+12 -5
View File
@@ -5,13 +5,12 @@ namespace Snowflake\Crontab;
use Exception;
use HttpServer\Server;
use Snowflake\Abstracts\Config;
use Snowflake\Cache\Redis;
use Snowflake\Exception\ConfigException;
use Snowflake\Process\Process;
use Snowflake\Snowflake;
use Swoole\Coroutine;
use Swoole\Timer;
use Throwable;
/**
@@ -62,16 +61,24 @@ class Zookeeper extends Process
* @throws Exception
*/
public function onHandler(\Swoole\Process $process): void
{
Timer::tick(80, [$this, 'loop']);
}
/**
* @throws ConfigException
* @throws Exception
*/
public function loop()
{
$redis = Snowflake::app()->getRedis();
while (true) {
defer(fn() => $redis->release());
$range = $this->loadCarobTask($redis);
var_dump($range);
foreach ($range as $value) {
$this->dispatch($redis, $value);
}
Coroutine::sleep(80);
}
}