Tarth
is an asynchronous, concurrent, distributed task process framework.
- PHP 5.3 or Higher
- A POSIX compatible operating system (Linux, OSX, BSD)
- POSIX and PCNTL extensions for PHP
- Redis extensions
- Asynchronous API callback, multi API callback
- Support timing callback, similar to crontab, but include retry, security, controllable options
- Support task number limit, speed controller
- Support callback priority level
- Stark Features
You can use Stark
to start the timer and processor daemon:
php vendor/got/stark/src/Stark/run.php -f scripts/timer.ini
php vendor/got/stark/src/Stark/run.php -f scripts/processor.ini
Use Stark
Class: \Tarth\Tool\Task
static public function createApiTask($url, $method = 'GET', $params = array())
static public function createEmailTask($to, $subject, $message)
static public function atomTask()
static public function exec()
static public function closeTask($taskId)
static public function getTarthHeader(TaskInterface $task)
static public function isRequestFromTarth()
<?php
require_once __DIR__ . '/../vendor/autoload.php';
\Tarth\Tool\Redis::setCacheServer('127.0.0.1:6379');
\Tarth\Tool\Redis::setQueueServer('127.0.0.1:6379');
$task = \Tarth\Tool\Task::createApiTask('http://alleria.mcp.wap.grid.sina.com.cn/test/normal');
echo \Tarth\Tool\Task::exec();
<?php
require_once __DIR__ . '/../vendor/autoload.php';
$task = \Tarth\Tool\Task::createApiTask('http://alleria.mcp.wap.grid.sina.com.cn/test/normal?case=timer&time=' . time());
$task->runAfter(100);
echo \Tarth\Tool\Task::exec();
<?php
require_once __DIR__ . '/../vendor/autoload.php';
$task = \Tarth\Tool\Task::createApiTask('http://alleria.mcp.wap.grid.sina.com.cn/test/normal?case=atom&index=1&date=' . date('YmdHis'));
$task = \Tarth\Tool\Task::createApiTask('http://alleria.mcp.wap.grid.sina.com.cn/test/normal?case=atom&index=2&date=' . date('YmdHis'));
echo \Tarth\Tool\Task::exec();
<?php
require_once __DIR__ . '/../vendor/autoload.php';
$task = \Tarth\Tool\Task::createApiTask('http://alleria.mcp.wap.grid.sina.com.cn/test/normal?case=atom&index=1&date=' . date('YmdHis'));
$task = \Tarth\Tool\Task::createApiTask('http://alleria.mcp.wap.grid.sina.com.cn/test/normal?case=atom&index=2&date=' . date('YmdHis'));
$task = \Tarth\Tool\Task::atomTask();
$task->runAfter(600)->canClose();
echo \Tarth\Tool\Task::exec();
See Stark
[queue]
type = "redis"
host = "127.0.0.1"
port = "6379"
key = "tarth-queue-0 tarth-queue-1 tarth-queue-2"
<?php
\Tarth\Tool\Redis::setCacheServer('127.0.0.1:6379');
\Tarth\Tool\Redis::setQueueServer('127.0.0.1:6379');
public function setPriority($level)
public function setMaxPerSecond($max)
public function setMaxPerMinute($max)
public function setMaxPerHour($max)
public function setMaxPerDay($max)
public function forbidDuplicate()
public function canClose()
public function runAt($timestamp)
public function runAfter($seconds)