weedgood / googlecloud-pubsub-laravel-queue-driver by JarvisHo
forked from twipi-group/googlecloud-pubsub-laravel-queue-driver

Google Cloud PubSub driver for Laravel/Lumen Queue.
55
0
0
Package Data
Maintainer Username: JarvisHo
Maintainer Contact: alexis.gomez.182@gmail.com (Alexis Gomez)
Package Create Date: 2023-11-14
Package Last Update: 2023-11-14
Language: PHP
License: MIT
Last Refreshed: 2024-11-17 03:09:16
Package Statistics
Total Downloads: 55
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 0
Total Forks: 0
Total Open Issues: 0

googlecloud-pubsub-php-adapter

A Google Cloud PubSub driver for Laravel/Lumen Queue.

CI Minimum PHP Version Software License

Installation

You can easily install this package via Composer using this command:

composer require twipi-group/googlecloud-pubsub-laravel-queue-driver

Laravel

Register this package by adding the following line to the autoloaded service providers of your config/app.php file:

TwipiGroup\GoogleCloudPubSubLaravelQueueDriver\GcServiceProviderQueue::class,

Lumen

For Lumen usage, the service provider should be registered manually as follow in your boostrap/app.php file:

$app->configure('queue');
$app->register(TwipiGroup\GoogleCloudPubSubLaravelQueueDriver\GcServiceProviderQueue::class);

Configuration

Add new connection named gcpubsub to your config/queue.php file. You can customize the following options directly from your .env file.

'gcpubsub' => [
    'driver' => 'gcpubsub',
    'project_id' => env('PUBSUB_PROJECT_ID', 'google-cloud-project-id'), // Google cloud project id
    'queue' => env('PUBSUB_QUEUE_DEFAULT', 'default'), // Default queue name corresponding to the gc pubsub topic
    'topic_suffix' => env('PUBSUB_TOPIC_SUFFIX', ''),
    'subscriber_suffix' => env('PUBSUB_SUBSCRIBER_SUFFIX', ''),
    'max_tries' => env('PUBSUB_JOB_MAX_TRIES', 1), // Number of times the job may be attempted.
    'retry_delay' => env('PUBSUB_JOB_RETRY_DELAY', 0), // Delay in seconds before retrying a job that has failed 
],

Running The Queue Worker

You may run the worker using the queue:work Artisan command. (Laravel documentation)

php artisan queue:work gcpubsub [--queue=myqueue]

When APP_DEBUG=true in your .env file, you can check google cloud subscribers from the queue worker output.

Tests

vendor/bin/phpunit tests

Contribution

You can contribute to this package by discovering bugs, opening issues or purpose new features.

Licence

This project is licensed under the terms of the MIT license. See License file for more information.