Skip to content

feat(taskqueue): migrate push queue client to Cloud Tasks v2 SDK - #117

Open
riddhi-shivhare wants to merge 34 commits into
GoogleCloudPlatform:masterfrom
riddhi-shivhare:taskqueue-migration-preview
Open

riddhi-shivhare wants to merge 34 commits into
GoogleCloudPlatform:masterfrom
riddhi-shivhare:taskqueue-migration-preview

Conversation

@riddhi-shivhare

Copy link
Copy Markdown

Description

Prepares the App Engine TaskQueue PHP SDK for General Availability (GA) by routing Push Queue operations to the official Google Cloud Tasks v2 client SDK (google/cloud-tasks ^2.0).

Changes Summary

  1. Dependency Addition (composer.json):

    • Added "google/cloud-tasks": "^2.0" to require.
  2. Dual Environment Variable Routing (PushQueue.php):

    • Added support for routing push tasks via either:
      • GAE_PUSHQUEUE_BACKEND: CLOUD_TASK
      • APPENGINE_USE_CLOUDTASK_PUSH_QUEUE: true / 1
  3. Task Creation (PushQueue.php):

    • Single Task Creation: Uses \Google\Cloud\Tasks\V2\Client\CloudTasksClient with \Google\Cloud\Tasks\V2\CreateTaskRequest and AppEngineHttpRequest.
    • Batch Task Creation (addTasks):
      • Automatically inspects the client for native batchCreateTasks support (BatchCreateTasksRequest) for future GA client library updates.
      • Gracefully falls back to sequential createTask calls when batchCreateTasks is not yet generated in the installed google/cloud-tasks package, ensuring reliability across all versions.
  4. Request Normalization & Error Mapping:

    • Properly normalizes HTTP method enum integers, AppEngineHttpRequest relative URIs, headers (Content-Type, X-AppEngine-QueueName, X-AppEngine-TaskName), and delay schedules (Google\Protobuf\Timestamp).
    • Maps Cloud Tasks ALREADY_EXISTS (code 6 / 409) and tombstoned task errors to TaskAlreadyExistsException, preserving legacy SDK exception precedence.
    • Enforces the legacy 100 KB payload size limit and regex task name validation.

Verification

All changes were deployed and validated against live App Engine Standard (PHP 8.2) in project rshivhare-demo-2016950:

Test Suite Case Description Result
Test 1: Push Single Task Standard push task to default queue PASS
Test 2: Deduplication Duplicate task name throws TaskAlreadyExistsException PASS
Test 3: Push Batch Multiple tasks enqueued via addTasks PASS
Test 4: Invalid Task Name Spaces in task name throws InvalidArgumentException PASS
Test 5: Task Too Large Payload > 100 KB throws TaskQueueException PASS
Test 6: Unknown Queue Non-existent queue throws TaskQueueException (FAILED_PRECONDITION) PASS

gajjarc and others added 30 commits July 5, 2026 10:11
…o TaskAlreadyExistsException for tombstoned tasks
…equest with relativeUri, removing convertToDotNotation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants