-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa1b2a7
commit 643c93a
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* 任务模板基类 定义格式 | ||
* User: Siam | ||
* Date: 2019/11/27 | ||
* Time: 9:12 | ||
*/ | ||
|
||
namespace Siam\AbstractInterface; | ||
|
||
|
||
abstract class CronAbstract | ||
{ | ||
public function __construct() | ||
{ | ||
set_time_limit(0); | ||
} | ||
|
||
/** | ||
* 写明监控时间周期 | ||
* @return mixed | ||
*/ | ||
abstract function rule(); | ||
|
||
/** | ||
* 执行逻辑 | ||
* @return mixed | ||
*/ | ||
public function run(){ | ||
$data = $this->before(); | ||
|
||
$res = $this->doJob($data); | ||
|
||
return $this->after($res); | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
abstract function before(); | ||
|
||
/** | ||
* @param null $data | ||
* @return bool | ||
*/ | ||
abstract function doJob($data = NULL); | ||
|
||
/** | ||
* @param bool $res | ||
* @return mixed | ||
*/ | ||
abstract function after($res = true); | ||
|
||
protected function log($string) | ||
{ | ||
echo date('Y-m-d H:i:s')." {$string} ". PHP_EOL; | ||
} | ||
} |