承接 underpin/background-process-loader 相关项目开发

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

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

underpin/background-process-loader

Composer 安装命令:

composer require underpin/background-process-loader

包简介

Asynchronous, background process loader for Underpin.

README 文档

README

Background Processing Integration for the Underpin WordPress framework.

As originally described by Delicious Brains:

WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks. Check out the example plugin or read the accompanying article.

Benefits of using this inside Underpin:

  1. Everything works inside of Underpin's registry, which works quite well with how Background Processing works.
  2. Underpin extends Background Processing to use Underpin's event logging.

Installation

Using Composer

composer require underpin/background-process-loader

Manually

This plugin uses a built-in autoloader, so as long as Background Processing is required before this extension, it should work as-expected.

require_once(__DIR__ . '/underpin-background-processes/underpin-background-process.php');

Setup

  1. Install this loader.
  2. Install Underpin. See Underpin Docs
  3. Create Background_Process or Async_Request classes.
  4. Register processes using Underpin.

Working With Async Tasks

From Delicious Brains:

Async requests are useful for pushing slow one-off tasks such as sending emails to a background process. Once the request has been dispatched it will process in the background instantly.

underpin()->async_requests()->add( 'key', [
	'action'               => 'key',        // Action Name. Must be unique.
	'task_action_callback' => function () { // Callback to fire
		// do things
	},
] );

Alternatively, you can extend Async_Request and reference the extended class directly, like so:

underpin()->async_request()->add('key','Namespace\To\Class');

Once registered, you can run the action any time like so:

underpin()->async_requests()->dispatch( 'key' );

Working With Background Processes

From Delicious Brains:

Background processes work in a similar fashion to async requests but they allow you to queue tasks. Items pushed onto the queue will be processed in the background once the queue has been dispatched. Queues will also scale based on available server resources, so higher end servers will process more items per batch. Once a batch has completed the next batch will start instantly.

Health checks run by default every 5 minutes to ensure the queue is running when queued items exist. If the queue has failed it will be restarted.

Queues work on a first in first out basis, which allows additional items to be pushed to the queue even if it’s already processing.

You can register a background process directly just like any other loader, like so:

underpin()->background_processes()->add( 'example', [
	'action'               => 'example_action_name', // Action Name. Must be unique.
	'task_action_callback' => function ( $item ) {   // Callback to fire on a single item.
	  // Do an action
	},
] );

task_action_callback should contain any logic to perform on the queued item. Return false to remove the item from the queue or return $item to push it back onto the queue for further processing. If the item has been modified and is pushed back onto the queue the current state will be saved before the batch is exited.

Alternatively, you can extend Background_Process and reference the extended class directly, like so:

underpin()->background_processes()->add('key','Namespace\To\Class');

Once registered, you can add as many items as necessary to the queue:

underpin()->background_processes()->enqueue( 'key', ['args' => 'to pass to task_action_callback'] );

Finally, when you're done enqueueing items, you can dispatch the processor to run the process on each enqueued item:

underpin()->background_processes()->dispatch( 'key' );

underpin/background-process-loader 适用场景与选型建议

underpin/background-process-loader 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 07 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 underpin/background-process-loader 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2021-07-19