承接 vanilla/garden-progress 相关项目开发

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

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

vanilla/garden-progress

Composer 安装命令:

composer require vanilla/garden-progress

包简介

A PHP package for representing progress made in a long running task.

README 文档

README

CI Packagist Version MIT License

When you have long-running operations it can be useful for both UX and debugging to know at any given point in time what part of the operation is currently being executed, how much work has been completed, and how much work remains.

This package is a standardized structure of storing such data, with an easy API for tracking it over time and merging multiple types of progress together.

Installation

composer require vanilla/garden-progress

Usage

Tracking Progress

use Garden\Progress\Progress;

$progress = new Progress();

$step1 = $progress->step("step1");

// Optional but completion is generally more easily tracked if you know how much work there is to do.
$step1->setTotal(count($thingsToDo));

// Track a bunch of work at once.
try {
    $thing->doWorkOnItems($thingsToDo);
    $step1->incrementSuccess(count($thingsToDo));
} catch (Exception $failed) {
    // Handle your error.
    $step1->incrementFailed(count($thingsToDo));
}

// Track specific IDs.
foreach ($thingsToDo as $thingID) {
    try {
        $thing->doThing($thingID);
        $step1->trackSuccessID($thingID);
    } catch (Throwable $e) {
        $step1->trackFailedID($thingID, $e);
    }
}

// Access current completion
$progress->step("step1")->completion->countFailed;
$progress->step("step1")->completion->countTotal;
$progress->step("step1")->completion->countSuccess;

$progress->step("step1")->transientData->successIDs;
$progress->step("step1")->transientData->failedIDs;
$progress->step("step1")->transientData->errorsByID[$someID]["message"] ?? null;

Serializing and Deserializing as JSON

use Garden\Progress\Progress;

// You dump it down to an array/json
$progress = new Progress();
$progress
    ->step("step1")
    ->setTotal(10)
    ->incrementSuccess(10);
$progress
    ->step("step2")
    ->setTotal(20)
    ->incrementFailed(20);
$json = json_encode($progress);

// And pull it back out again.
$fromJson = Progress::fromArray(json_decode($progress, true));

Merging Progress

Progresses are meant to merged. Completion and transient data for each step will be merged.

use Garden\Progress\Progress;

$progress1 = new Progress();
$progress1->step("step1");

$progress2 = new Progress();
$progress2->step("step2");

$progress3 = new Progress();
$progress3->step("step2");
$progress3->step("step3");

$merged = $progress1->merge($progress2, $progress3);
// All these were merged together.
$merged->step("step1");
$merged->step("step2");
$merged->step("step3");

Job Progress Complex Example

{
    // General label for the thing being progress.
    name: "Doing the job",
    // Many jobs may only have 1 step being tracked, but a more complex job may have multiple.
    steps: {
        // Steps are named
        "A step name": {
            name: "A step name",
            // Each step tracks progress.
            // Progress accumulates over time.
            completion: {
                countTotal: 54103,
                countComplete: 4200,
                countFailed: 4,
            },
            // Transient IDs can be useful for something watching a job progress intimately.
            // Only a small amount of these should ever accumulate in storage systems
            // As they could easily become too much in a large process.
            // Many types of jobs will not return this data at all.
            transientData: {
                successIDs: [51, 590, 131, 32],
                failedIDs: [12, 15, 43, 452],
                errorsByID: {
                    "452": {
                        message: "You do not have permission to modify this article",
                        code: 403,
                    },
                },
            },
        },
    },
}

vanilla/garden-progress 适用场景与选型建议

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

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

围绕 vanilla/garden-progress 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-03