改名
This commit is contained in:
+58
-15
@@ -6,13 +6,13 @@ namespace Snowflake;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Snowflake\Abstracts\BaseObject;
|
||||
|
||||
/**
|
||||
* Class Async
|
||||
* @package Snowflake
|
||||
*/
|
||||
class Crontab extends Component
|
||||
class Crontab extends BaseObject
|
||||
{
|
||||
|
||||
|
||||
@@ -36,6 +36,62 @@ class Crontab extends Component
|
||||
|
||||
private int $execute_number = 0;
|
||||
|
||||
/**
|
||||
* @return array|Closure
|
||||
*/
|
||||
public function getHandler(): array|Closure
|
||||
{
|
||||
return $this->handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParams(): mixed
|
||||
{
|
||||
return $this->params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTickTime(): int
|
||||
{
|
||||
return $this->tickTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isLoop(): bool
|
||||
{
|
||||
return $this->isLoop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaxExecuteNumber(): int
|
||||
{
|
||||
return $this->max_execute_number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getExecuteNumber(): int
|
||||
{
|
||||
return $this->execute_number;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array|Closure $handler
|
||||
@@ -94,19 +150,6 @@ class Crontab extends Component
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function dispatch()
|
||||
{
|
||||
$redis = Snowflake::app()->getRedis();
|
||||
|
||||
$executeTime = $this->tickTime + time();
|
||||
|
||||
$redis->zAdd('system:crontab', (string)$executeTime, serialize($this));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user