This commit is contained in:
2021-04-23 12:03:24 +08:00
parent c908ac1a8e
commit 8004bd4a16
+7 -10
View File
@@ -42,7 +42,7 @@ class Zookeeper extends Process
/** /**
* @param \Swoole\Process $process * @param \Swoole\Process $process
* @throws \Snowflake\Exception\ConfigException * @throws Exception
*/ */
public function before(\Swoole\Process $process): void public function before(\Swoole\Process $process): void
{ {
@@ -61,25 +61,22 @@ class Zookeeper extends Process
*/ */
public function onHandler(\Swoole\Process $process): void public function onHandler(\Swoole\Process $process): void
{ {
$ticker = Config::get('crontab.ticker', 50) / 1000;
$redis = Snowflake::app()->getRedis(); $redis = Snowflake::app()->getRedis();
while (true) { while (true) {
$range = $this->loadCarobTask($redis); $range = $this->loadCarobTask($redis);
foreach ($range as $value) { foreach ($range as $value) {
$this->dispatch($redis, $value); $this->dispatch($redis, $value);
} }
Coroutine::sleep($ticker); Coroutine::sleep(200);
} }
} }
/** /**
* @param $server * @param Redis|\Redis $redis
* @param Redis|\Redis $redis * @param $value
* @param int $setting * @throws Exception
* @param $value */
* @throws Exception
*/
private function dispatch(Redis|\Redis $redis, $value) private function dispatch(Redis|\Redis $redis, $value)
{ {
try { try {