承接 got/tarth 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

got/tarth

Composer 安装命令:

composer require got/tarth

包简介

请求异步化框架

README 文档

README

Tarth is an asynchronous, concurrent, distributed task process framework.

Requires

  • PHP 5.3 or Higher
  • A POSIX compatible operating system (Linux, OSX, BSD)
  • POSIX and PCNTL extensions for PHP
  • Redis extensions

Features

  • 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

Usage

You can use Stark to start the timer and processor daemon:

php vendor/bin/stark -f scripts/timer.ini
php vendor/bin/stark -f scripts/processor.ini

Daemon

Use Stark

Task Tools

API

Class: \Tarth\Tool\Task

Create

static public function createApiTask($url, $method = 'GET', $params = array())
static public function createEmailTask($to, $subject, $message)

Control

static public function atomTask()
static public function exec()
static public function closeTask($taskId)

Security

static public function getTarthHeader(TaskInterface $task)
static public function isRequestFromTarth()

Samples

Normal task

php tests/normal_api_task.php
<?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();

Timer task

php tests/timer_task.php
<?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();

Multi task

php tests/multi_task.php
<?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();

Atom task

php tests/atom_task.php
<?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();

Configs

Daemon configs

See Stark

Redis configs

Config in daemon ini

[queue]
type = "redis"
host = "127.0.0.1"
port = "6379"
key = "tarth-queue-0 tarth-queue-1 tarth-queue-2"

Change in tools

<?php
\Tarth\Tool\Redis::setCacheServer('127.0.0.1:6379');
\Tarth\Tool\Redis::setQueueServer('127.0.0.1:6379');

Task Options

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)

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固