richan-fongdasen/laravel-gcr-worker

Easily generates RESTful API endpoints in Laravel

1.4.1 2022-03-22 08:07 UTC

This package is auto-updated.

Last update: 2022-06-22 08:38:42 UTC


README

Build Status codecov Total Downloads Latest Stable Version License: MIT

Laravel GCR Worker

Simple background processing implementation with Google Cloud Run

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 - 9.x ^1.4

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.