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
Looking for Commercial Support?
Potato offers Commercial Support for all its Open Source projects and we can tailor a support package to your needs.
If you're interested in commercial support, training, or consultancy then go ahead and contact us at opensource@potatolondon.com
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.services.cloud_tasks.transports 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.
Specifying a target
Task queue needs to point at a service for outgoing requests. You can specify this with --target-host and --target-port
Testing
Run:
python gcloud_tasks_emulator/tests.py
Metadata
Release files for gcloud-tasks-emulator 0.6.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gcloud-tasks-emulator-0.6.2.tar.gz | 17.0 kB | Without provenance | Details for gcloud-tasks-emulator-0.6.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gcloud_tasks_emulator-0.6.2-py3-none-any.whl | Python 3 | none | any | Details for gcloud_tasks_emulator-0.6.2-py3-none-any.whl |
Total release size: 35.1 kB
Release files / gcloud-tasks-emulator-0.6.2.tar.gz
| Download URL | gcloud-tasks-emulator-0.6.2.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
512f0711fde211966f620584a2202977b49d27e1f948322e7f9d498f5d5aca0f
|
|
BLAKE2b-256 checksum How to use checksums |
1a22fb9a6ceb930b3cffd22b891bd7a88da657c168cde3f6402aaa243365745b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.17
|
Release files / gcloud_tasks_emulator-0.6.2-py3-none-any.whl
| Download URL | gcloud_tasks_emulator-0.6.2-py3-none-any.whl |
|---|---|
| Size | 18.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
723da63bd1b70dc8e0444082810f9174c05b557934ade613f5c501102beb63a8
|
|
BLAKE2b-256 checksum How to use checksums |
d8f4bd2822a71f08d8ef174cd90befaffcf1b70c42d5c323d2ffe7dc8efc97a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.17
|
Security for gcloud-tasks-emulator 0.6.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.