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
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.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.
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gcloud-tasks-emulator-0.5.2.tar.gz
.
File metadata
- Download URL: gcloud-tasks-emulator-0.5.2.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b743a6d2727587f25fb8a85b24c027ba9946744b07bab9957f2879ed73a9e08b |
|
MD5 | 50f713d6b70950c7d11fa30f445bf2ba |
|
BLAKE2b-256 | bec2ecbfe03c91c80f4ba0eae6dc22ff4f57ed24dd3d5e86e7f285d13fc6dcc9 |
File details
Details for the file gcloud_tasks_emulator-0.5.2-py3-none-any.whl
.
File metadata
- Download URL: gcloud_tasks_emulator-0.5.2-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 796bc1d03af8df59bb7b6ba247047214b9e25d881ab853fb8931683f717eba06 |
|
MD5 | 7854ca223f4dbf410baf90204351bc6b |
|
BLAKE2b-256 | 01ea70d5ef4185fd050292eb956efceba09f3bd53a9f2ee211c219c1b02da3b0 |