Skip to content

Configuration

Typed Tasks supports configuration at two levels: global defaults and per-task overrides.

Global Defaults

Set defaults for all queues when creating the typed tasks client:

typescript
export const tasks = createTypedTasks({
  client,
  definitions,
  projectId: "your-gcp-project-id",
  region: "us-central1",
  options: {
    memory: "512MiB",
    timeoutSeconds: 60,
    vpcConnector: "redis-connector",
    rateLimits: {
      maxDispatchesPerSecond: 5,
      maxConcurrentDispatches: 10,
    },
    retryConfig: {
      maxAttempts: 5,
      minBackoffSeconds: 10,
      maxBackoffSeconds: 3600,
    },
  },
});

Per-Task Overrides

Override global defaults for specific handlers:

typescript
export const handleRecalculate = tasks.createHandler({
  queueName: "recalculatePendingUpdates",
  options: {
    memory: "4GiB",
    timeoutSeconds: 540,
  },
  handler: async (data) => {
    // Expensive operation that needs more resources
  },
});

Handler-specific options are merged with global defaults, with handler options taking precedence.

Merge Order

Configuration is resolved in this order (later overrides earlier):

  1. Global defaults — set in createTypedTasks({ options })
  2. Handler options — set in createHandler({ options })

Factory Parameters

The createTypedTasks function accepts:

ParameterTypeRequiredDescription
clientCloudTasksClientYesGoogle Cloud Tasks client instance
definitionsTaskDefinitionRecordYesTask name to schema/options mapping
projectIdstringYesGCP project ID
regionstringYesGCP region for all task queues
optionsTaskHandlerOptionsNoGlobal defaults for all handlers

Released under the MIT License.