Skip to main content

A stub emulator for the Google Cloud Tasks API

Project description

Local Emulator for Google Cloud Tasks

Google doesn't (yet) ship an emulator for the Cloud Tasks API like they do for Cloud Datastore.

This is a stub emulator so you can run your tests and do local development without having to connect to the production Tasks API.

THIS IS A WORK IN PROGRESS NOT ALL API CALLS ARE COMPLETE

Usage

Start the emulator with:

gcloud-tasks-emulator start --port=9090

Then from within your code, use the following (instead of your normal production client connection)

Python

import grpc
from google.cloud.tasks_v2 import CloudTasksClient
from google.cloud.tasks_v2.gapic.transports.cloud_tasks_grpc_transport import CloudTasksGrpcTransport

client = CloudTasksClient(
    transport=CloudTasksGrpcTransport(channel=grpc.insecure_channel("127.0.0.1:9090"))
)

Node.js

const grpc = require("@grpc/grpc-js");
const { CloudTasksClient } = require('@google-cloud/tasks');

const client = new CloudTasksClient({
    servicePath: "localhost",
    port: 9090,
    sslCreds: grpc.credentials.createInsecure()
});

Java

import com.google.api.gax.core.NoCredentialsProvider;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.cloud.tasks.v2.CloudTasksClient;
import com.google.cloud.tasks.v2.CloudTasksSettings;
import io.grpc.ManagedChannelBuilder;

CloudTasksSettings settings = CloudTasksSettings.newBuilder()
        .setCredentialsProvider(NoCredentialsProvider.create())
        .setTransportChannelProvider(
                InstantiatingGrpcChannelProvider.newBuilder()
                        .setEndpoint("localhost:9090")
                        .setChannelConfigurator(ManagedChannelBuilder::usePlaintext)
                        .build()
        )
        .build();
CloudTasksClient client = CloudTasksClient.create(settings);

The 'default' queue

By default, the emulator won't create a 'default' queue, however you can enable this by passing the fully-qualified name of the queue:

gcloud-tasks-emulator start --default-queue=projects/[PROJECT]/locations/[LOCATION]/queues/default

Specifying a queue.yaml

If your project uses a queue.yaml file, you can create default queues by passing its path to the --queue-yaml argument.

Additionally, you'll likely want to pass --queue-yaml-project and --queue-yaml-location to generate the correct fully qualified queue names. These settings will otherwise default to "[PROJECT]" and "[LOCATION]" respectively.

Testing

Run:

python gcloud_tasks_emulator/tests.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gcloud-tasks-emulator-0.4.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

gcloud_tasks_emulator-0.4.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file gcloud-tasks-emulator-0.4.0.tar.gz.

File metadata

  • Download URL: gcloud-tasks-emulator-0.4.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for gcloud-tasks-emulator-0.4.0.tar.gz
Algorithm Hash digest
SHA256 9262ba970fdc602fcdb75b093d46aed38376c782bc61d683ce3c800e5419d483
MD5 885239fc8bd5b26679911645dc8fd0b6
BLAKE2b-256 b04716729f41b6d88cfdae85bb0c8c62eaa95cb09ddfd9a7021bae203fcd4141

See more details on using hashes here.

File details

Details for the file gcloud_tasks_emulator-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: gcloud_tasks_emulator-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for gcloud_tasks_emulator-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da6fe3fce8c64616a9e6ae1fc122ec3b96d23e8f17bf1fb7ab0abb0599b67f16
MD5 ffc12f2b15cbc43c5f218281e32585a0
BLAKE2b-256 cab118ddb12c7d7080776775003cf812841d5a453e2c1af03f3997bf483c924f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page