承接 sinemacula/laravel-async-polling 相关项目开发

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

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

sinemacula/laravel-async-polling

最新稳定版本:v1.0.1

Composer 安装命令:

composer require sinemacula/laravel-async-polling

包简介

A simple polling trait, designed to extend Laravel's queued jobs with asynchronous polling

README 文档

README

Build Status StyleCI Maintainability Test Coverage

This repository provides a simple polling trait, designed to extend Laravel's queued jobs with asynchronous polling capabilities. It's a straightforward solution for jobs that require repeated checks or waiting for specific conditions before proceeding.

Features

  • Effortless Integration: Add polling functionality to any Laravel job with just one trait.
  • Customizable Polling Logic: Implement your own polling logic with abstract methods.
  • Resource Efficient: Smart handling of execution time and memory limits.

Installation

Install the package via Composer:

composer require sinemacula/laravel-async-polling

Usage

  1. Use the Trait in Your Job Class: Import and use HandlesPolling in your Laravel job.
use SineMacula\Jobs\Traits\HandlesPolling;

class ExampleJob implements ShouldQueue
{
    use HandlesPolling;

    // Implement required abstract methods (see Step 2)
}
  1. Implement Abstract Methods: Provide implementations for abstract methods defined in the trait to tailor the polling process.
/**
 * Get the id to uniquely identify the polling job.
 *
 * @return string
 */
protected function getPollingId(): string
{
    // Return a unique identifier for the polling job
    
    // Example:
    return $this->uniqueId();
}

/**
 * Determine whether the polling job has resolved.
 *
 * @return bool
 */
protected function hasPollResolved(): bool
{
    // Return true if the polling job has successfully resolved
    
    // Example:
    return $this->isStatusFinite($this->status);
}

/**
 * Resolve the polling job to be dispatched.
 *
 * @return \Illuminate\Contracts\Queue\ShouldQueue
 */
protected function resolvePollingJob(): ShouldQueue
{
    // Resolve the job to be released back to the queue. This function will
    // most likely just return `new static` but it is here to allow for new
    // parameters to be passed to the next instance of the poll. This method
    // will only be executed when job release is not supported.
    
    // Example:
    return new static($this->status);
}

/**
 * Resolve the poll.
 *
 * @return bool
 */
protected function resolvePoll(): bool;
{
    // Here is where you insert the logic for the actual poll
    
    // Example
    $response = SomethingCool::getStatus($this->someProperty);

    $this->someCustomMethod($response);

    return $this->hasPollResolved();
}
  1. Customisation Configuration: If you would like to override certain configurations, you can do so by defining any of the following methods:
/**
 * Determine whether jobs can be released.
 *
 * @return bool
 */
protected function canJobsBeReleased(): bool
{
    return config('some.configuration', self::SUPPORTS_JOB_RELEASE);
}

/**
 * Get the interval of the poll.
 *
 * @return int
 */
protected function getInterval(): int
{
    return config('some.configuration', self::DEFAULT_INTERVAL);
}

/**
 * Get the maximum allowed number of attempts.
 *
 * @return int
 */
protected function getMaxAttempts(): int
{
    return config('some.configuration', self::DEFAULT_MAX_ATTEMPTS);
}

/**
 * Get the maximum lifetime of the poll.
 *
 * @return int
 */
protected function getLifetime(): int
{
    return config('some.configuration', self::DEFAULT_LIFETIME);
}

License

The Laravel Async Polling repository is open-sourced software licensed under the Apache License, Version 2.0.

sinemacula/laravel-async-polling 适用场景与选型建议

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

它主要适用于以下技术方向: 「laravel」 「queues」 「polling」 「sine macula」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2024-01-29