承接 norberttech/symfony-process-executor 相关项目开发

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

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

norberttech/symfony-process-executor

Composer 安装命令:

composer require norberttech/symfony-process-executor

包简介

Symfony Process Component on steroids, async/sync execution chain.

README 文档

README

Tests

Tiny library that simplifies launching multiple processes in parallel (or not).

Installation

composer require norberttech/symfony-process-executor

Examples

<?php

use NorbertTech\SymfonyProcessExecutor\AsynchronousExecutor;
use NorbertTech\SymfonyProcessExecutor\ProcessPool;
use NorbertTech\SymfonyProcessExecutor\ProcessWrapper;
use Symfony\Component\Process\Process;
use Aeon\Calendar\TimeUnit;

$processes = new ProcessPool(
    Process::fromShellCommandline('sleep 1 && echo 1'),
    Process::fromShellCommandline('sleep 2 && echo 2'),
    Process::fromShellCommandline('sleep 3 && echo 3'),
    Process::fromShellCommandline('sleep 4 && echo 4'),
    Process::fromShellCommandline('sleep 5 && echo 5')
);

$executor = new AsynchronousExecutor(
    pool: $processes,
    sleep: TimeUnit::milliseconds(100), // delay between checking for process completion
    timeout: TimeUnit::seconds(12),  // total timeout for all processes
    batchSize: 2 // number of processes to run in parallel at once, when null all processes will be run in parallel
);

$executor->execute();

$executor->pool()->each(function (ProcessWrapper $processWrapper) {
    var_dump($processWrapper->exitCode());
    var_dump(\trim($processWrapper->output()));
    var_dump($processWrapper->executionTime()->inSeconds());
    var_dump($processWrapper->executionTime()->inMilliseconds());
    var_dump($processWrapper->executionTime()->microsecond());
    echo "----\n";
});

echo \sprintf("Successfully finished child processes: %d\n", $executor->pool()->withSuccessExitCode());
echo \sprintf("Failure finished child processes: %d\n", $executor->pool()->withFailureExitCode());
echo \sprintf("Total execution time [s]: %d\n", $executor->executionTime()->inSecondsPreciseString());

Output:

php examples/async_multiple_success_processes.php 

int(0)
string(1) "1"
int(1)
int(1033)
int(1033295)
----
int(0)
string(1) "2"
int(2)
int(2064)
int(2064680)
----
int(0)
string(1) "3"
int(3)
int(3092)
int(3092137)
----
int(0)
string(1) "4"
int(4)
int(4026)
int(4026060)
----
int(0)
string(1) "5"
int(5)
int(5052)
int(5052531)
----
Successfully finished child processes: 5
Failure finished child processes: 0
Total execution time [s]: 5

Tests

All tests for this library are written as phpt files, you can read more about it here https://qa.php.net/phpt_details.php.

In order to launch full testsuite use composer

composer tests

norberttech/symfony-process-executor 适用场景与选型建议

norberttech/symfony-process-executor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 178.06k 次下载、GitHub Stars 达 22, 最近一次更新时间为 2020 年 04 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 norberttech/symfony-process-executor 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 178.06k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 22
  • 点击次数: 7
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 22
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-23