Tasks API
Asynchronous task queue management with Google Cloud Tasks integration.
What It Does
The Tasks API provides a fluent, builder-pattern interface for enqueueing asynchronous tasks using Google Cloud Tasks. It enables services to queue work for later processing without blocking requests, with support for scheduling, deduplication, and secure service-to-service communication via OIDC authentication.
Key Capabilities
| Capability | Description |
|---|---|
| Task Queue Management | Enqueue tasks to Google Cloud Tasks queues with exponential backoff retry |
| Scheduling Support | Schedule tasks up to 30 days in advance with time validation |
| Deduplication | MD5-based deduplication keys prevent duplicate task processing |
| Builder Pattern | Fluent API for constructing and posting tasks |
| Multi-Service Communication | Reliable message passing between microservices |
| Cloud Function Support | Enqueue tasks to Google Cloud Functions with automatic URI resolution |
| OIDC Authentication | Secure service-to-service authentication via OIDC tokens |
| Payload Validation | Validate required fields before posting tasks |
| Event-Based Deduplication | Deduplication from Engineering11 event IDs |
| Cross-Project Support | Route tasks across GCP projects |
Configuration
Default Configuration
- Queue Location: us-central1
- Retry Attempts: 5
- Deduplication: MD5 hashing
- Authentication: OIDC tokens
Cloud Tasks Limits
- Schedule Limit: 30 days in advance
- Named Task Limit: Automatic deduplication
- Payload Size: 100KB max (Cloud Tasks limit)
Required Environment Variables
- GCP Project: Auto-detected from environment
- Service Account: Retrieved from GCP metadata
Exports
Classes
TaskService- Core task managementTaskBuilder- Fluent task constructionMockTaskService- Testing mockTaskOptions- Task configurationTaskBody- Task payload
Functions
sendToTask()- High-level task sendingallKeys()- CRC-32 based deduplication
Types and Interfaces
ICloudTaskSpec- Task specificationDedupKeySpec- Deduplication configurationITaskPayload- Base payload interfaceIFunctionTaskOptions- Function task configuration
Constants
- Error types and defaults
Common Use Cases
- Async processing: Queue long-running operations without blocking requests
- Email sending: Queue email tasks for batch processing
- Data processing: Schedule ETL jobs and batch operations
- Notifications: Send delayed or scheduled notifications
- Webhooks: Reliable webhook delivery with retries
- Cross-service communication: Message passing between microservices
- Scheduled jobs: Cron-like task scheduling
- Rate limiting: Queue tasks to prevent API rate limits
Roadmap
Multi-Cloud Support
This API currently supports Google Cloud Platform. Future versions will add support for additional cloud providers and container-based deployment options, enabling greater flexibility in infrastructure choices.
What Customers Don’t Have to Build
- Google Cloud Tasks integration
- Fluent builder pattern interfaces
- Deduplication key generation (MD5, CRC-32)
- Task scheduling validation
- Cloud Function URI resolution
- OIDC authentication setup
- Exponential backoff retry logic
- Payload validation framework
- Base64 payload encoding
- App Engine routing
- Cross-project task routing
- Service account management
- Named task creation
- Time-window deduplication
- Task payload serialization
- Error handling for transient failures
- Queue location management
- Cross-organization routing
Last updated on