richan-fongdasen/laravel-gcr-worker

Easily generates RESTful API endpoints in Laravel

1.6.0 2024-03-13 10:57 UTC

This package is auto-updated.

Last update: 2024-04-13 11:06:18 UTC


README

Build codecov Total Downloads Latest Stable Version License: MIT

Laravel GCR Worker

Simple background processing implementation with Google Cloud Run and Google Cloud Pub/Sub

Synopsis

This package would help you to implement any background processing in Laravel like queue worker or scheduled job in Google Cloud Run by handling the triggered HTTP event invocation.

Table of contents

Setup

Install the package via Composer :

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

Laravel version compatibility

Laravel version Package version
5.7 - 8.x 1.0 - 1.3
8.x - 11.x ^1.6

Configuration

Publish configuration file using php artisan command

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

The command above would copy a new configuration file to /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',
];

Usage

The content for this section is under development.

License

The MIT License (MIT). Please see License File for more information.