feat: Add Cloud Run Jobs support as queue target#187
Merged
marickvantuil merged 10 commits intostackkit:masterfrom Feb 12, 2026
Merged
feat: Add Cloud Run Jobs support as queue target#187marickvantuil merged 10 commits intostackkit:masterfrom
marickvantuil merged 10 commits intostackkit:masterfrom
Conversation
Enables dispatching jobs to Cloud Run Jobs instead of HTTP endpoints, allowing for long-running batch processing that exceeds Cloud Tasks HTTP timeout limits. This change introduces a new `cloud_run_job` configuration option for the `cloudtasks` queue connection. When enabled, jobs are dispatched to the Cloud Run Jobs execution API, passing the job payload as environment variables. A new artisan command `cloud-tasks:work-job` is introduced to handle Cloud Run Job executions. Large payloads exceeding environment variable limits can be stored in Laravel filesystem disks, and the path is passed to the Cloud Run Job instead.
- Add cloud-tasks:work-job Artisan command for processing jobs via Cloud Run Jobs - Support Cloud Run Jobs as a target type via Cloud Tasks execution API - Add GCS payload storage for large payloads (>10KB) using Laravel Filesystem - Container overrides pass CLOUD_TASKS_PAYLOAD, CLOUD_TASKS_TASK_NAME, CLOUD_TASKS_PAYLOAD_PATH env vars - Command reads env vars via getenv() and extracts connection from payload - Automatic cleanup of payload files after processing - 23 comprehensive unit tests with 30 assertions
Cloud Run Jobs API requires OAuth authentication with cloud-platform scope. - Changed from OidcToken to OAuthToken - Set scope to 'https://www.googleapis.com/auth/cloud-platform' - Updated test to verify OAuth token configuration
Added comprehensive section covering: - Project-level permissions (cloudtasks.enqueuer, cloudtasks.viewer, run.jobsExecutorWithOverrides, run.invoker) - Service account permissions (iam.serviceAccountUser for SA and Cloud Tasks agent) - Summary table with purpose of each permission
The library only creates/deletes tasks, it does not list queues or tasks. cloudtasks.viewer is only needed if your own application code lists queues/tasks.
Member
|
This is really nice, thanks! I will review everything later. |
Modifies the Cloud Run Job worker to handle job retries by releasing jobs back to Cloud Tasks instead of relying on Cloud Run's retry mechanism. This prevents duplicate job executions when retries are configured on the Cloud Run Job itself, as Laravel manages retries by pushing a new task back to Cloud Tasks when a job is released. This matches the same behaviour as the HTTP request handler Updates tests to reflect the change.
|
|
||
| #### Setup | ||
|
|
||
| 1. **Create a Cloud Run Job** with your Laravel application container, configured to run: |
Member
There was a problem hiding this comment.
I think this is a little confusing. The command cloud-tasks:work-job doesn't need to be called by the user but it seems like it should. I feel like the setup should start with configuring the queue connection through the config?
| 'queue' => env('CLOUD_TASKS_QUEUE', 'default'), | ||
|
|
||
| // Cloud Run Job configuration | ||
| 'cloud_run_job' => env('CLOUD_TASKS_USE_CLOUD_RUN_JOB', false), |
Member
There was a problem hiding this comment.
Maybe these options could be added to the main installation config section. But I'm not sure, as it's already quite a big configuration 😅
Member
|
Thanks, it looks really good! I left a few comments. I will go over it again tomorrow or Wednesday just to be sure, and tag it! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for processing Laravel queue jobs using Google Cloud Run Jobs as a target type. Instead of dispatching jobs to an HTTP endpoint, Cloud Tasks triggers a Cloud Run Job execution via the Cloud Run Jobs API, which runs an Artisan command to process the job.
Features
Configuration
Breaking Changes
None. This is an additive feature - the cloud_run_job option defaults to false, preserving existing behaviour.
Tests
Documentation