richan-fongdasen/laravel-gcr-worker

在 Laravel 中轻松生成 RESTful API 端点

1.6.0 2024-03-13 10:57 UTC

This package is auto-updated.

Last update: 2024-09-13 12:11:45 UTC


README

Build codecov Total Downloads Latest Stable Version License: MIT

Laravel GCR Worker

使用 Google Cloud Run 和 Google Cloud Pub/Sub 的简单后台处理实现

摘要

此包可以帮助您通过处理触发的 HTTP 事件调用,在 Google Cloud Run 中实现 Laravel 中的任何后台处理,如队列工作或计划任务。

目录

设置

通过 Composer 安装此包

$ composer require richan-fongdasen/laravel-gcr-worker

Laravel 版本兼容性

配置

使用 php artisan 命令发布配置文件

$ php artisan vendor:publish --provider="RichanFongdasen\GCRWorker\ServiceProvider"

上面的命令会将新的配置文件复制到 /config/gcr-worker.php

return [

    /*
    |--------------------------------------------------------------------------
    | Allow Event invocation
    |--------------------------------------------------------------------------
    |
    | Specify whether the application would allow and handle any event
    | invocations, such as Pub/Sub topic message published events, Cloud
    | scheduler jobs, etc.
    |
    */

    'allow_event_invocation' => (bool) env('ALLOW_EVENT_INVOCATION', false),


    /*
    |--------------------------------------------------------------------------
    | Maximum Execution Time
    |--------------------------------------------------------------------------
    |
    | Set the max execution time in seconds, the default value is 15 minutes.
    |
    | Warning:
    | This value doesn't update the maximum execution time defined in your
    | nginx, apache or php-fpm configuration. You need to update them manually.
    |
    */

    'max_execution_time' => 60 * 15,


    /*
    |--------------------------------------------------------------------------
    | Middleware
    |--------------------------------------------------------------------------
    |
    | Define the middleware which should be attached in every GCR worker route.
    |
    */

    'middleware' => [
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
        \RichanFongdasen\GCRWorker\Middleware\AllowEventInvocation::class,
    ],


    /*
    |--------------------------------------------------------------------------
    | Path prefix
    |--------------------------------------------------------------------------
    |
    | Define the path prefix of the Pub/Sub event handler url.
    |
    */

    'path_prefix' => 'gcr-worker',
];

用法

本节内容正在开发中。

许可证

MIT 许可证(MIT)。请参阅 许可证文件 以获取更多信息。