承接 n-singularity/async 相关项目开发

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

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

n-singularity/async

Composer 安装命令:

composer require n-singularity/async

包简介

Asynchronous for Laravel

README 文档

README

this is a simple package for asynchronous laravel. Each task will be stored in the cache, and then will be executed in parallel with php artisan cli.

Setup

The preferred way to install this extension is through composer:

composer require n-singularity/async

After updating composer, add the ServiceProvider to the providers array in config/app.php

Nsingularity\Async\AsynchronousServiceProvider::class

Basic Usage

This package supports three types of functions that can be run in parallel:

1. Global Function

function sendEmail($email, $bodyEmail){
    //code to send email
}

function foo(){
    Nsingularity\Async\Async::globalFunction("sendEmail", ["email@example.com", "body email html"]);
    echo("done");
}

2. Function of Object

class Example
{
    public function sendEmail($email, $bodyEmail){
        //code to send email
        
    }
}

function foo(){
    Nsingularity\Async\Async::objectFunction(new Example, "sendEmail", ["email@example.com", "body email html"]);
    echo("done");
}

3. Object (must inplements AsyncableClassInterface)

class Example implements \Nsingularity\Async\AsyncableClassInterface
{
    private $email;
    
    private $bodyEmail;
    
    public function __construct($email, $bodyEmail){
        $this->email = $email;
        $this->bodyEmail = $bodyEmail;
    }
    
    public function handler(){
        //code to send email
        
    }
}

function foo(){
    Nsingularity\Async\Async::object(new Example("email@example.com", "body email html"));
    echo("done");
}

Get Response From Async

function createText($a, $b)
{
    sleep(5);
    return $a . " " . $b;
}

function foo(){
    $ts = time();
    $handler1 = Nsingularity\Async\Async::globalFunction("createText" ,["hello","world"]);
    $handler2 = Nsingularity\Async\Async::globalFunction("createText" ,["hello","hello"]);
    $handler3 = Nsingularity\Async\Async::globalFunction("createText" ,["world","world"]);
    
    $text1 = $handler1->get();
    $text2 = $handler2->get();
    $text3 = $handler3->get();
    
    $te = time();
    
    echo $text1." | ".$text2." | ".$text3." | ".$te-$ts; // hello world | hello hello | world world | 6
}

n-singularity/async 适用场景与选型建议

n-singularity/async 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 12 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 n-singularity/async 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 n-singularity/async 我们能提供哪些服务?
定制开发 / 二次开发

基于 n-singularity/async 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-13