# 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](mailto: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
```py
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
```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
```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
```
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/potato-oss/google-cloud/gcloud-tasks-emulator",
"name": "gcloud-tasks-emulator",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "Google Cloud Tasks, Google App Engine, GAE, GCP",
"author": "Potato London Ltd.",
"author_email": "mail@p.ota.to",
"download_url": "https://files.pythonhosted.org/packages/d6/d3/8c251543ef6bcb16a222d6166da7b341b5b4327ec80f7ecf59d9a70089be/gcloud-tasks-emulator-0.6.1.tar.gz",
"platform": null,
"description": "# Local Emulator for Google Cloud Tasks\n\nGoogle doesn't (yet) ship an emulator for the Cloud Tasks API like they do for\nCloud Datastore.\n\nThis is a stub emulator so you can run your tests and do local development without\nhaving to connect to the production Tasks API.\n\n**THIS IS A WORK IN PROGRESS NOT ALL API CALLS ARE COMPLETE**\n\n---\n\n## Looking for Commercial Support?\n\nPotato offers Commercial Support for all its Open Source projects and we can tailor a support package to your needs.\n\nIf you're interested in commercial support, training, or consultancy then go ahead and contact us at [opensource@potatolondon.com](mailto:opensource@potatolondon.com)\n\n---\n\n## Usage\n\nStart the emulator with:\n\n```\ngcloud-tasks-emulator start --port=9090\n```\n\nThen from within your code, use the following (instead of your normal production client connection)\n\n### Python\n\n```py\nimport grpc\nfrom google.cloud.tasks_v2 import CloudTasksClient\nfrom google.cloud.tasks_v2.services.cloud_tasks.transports import CloudTasksGrpcTransport\n\nclient = CloudTasksClient(\n transport=CloudTasksGrpcTransport(channel=grpc.insecure_channel(\"127.0.0.1:9090\"))\n)\n```\n\n### Node.js\n\n```js\nconst grpc = require(\"@grpc/grpc-js\");\nconst { CloudTasksClient } = require('@google-cloud/tasks');\n\nconst client = new CloudTasksClient({\n servicePath: \"localhost\",\n port: 9090,\n sslCreds: grpc.credentials.createInsecure()\n});\n```\n\n### Java\n\n```java\nimport com.google.api.gax.core.NoCredentialsProvider;\nimport com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;\nimport com.google.cloud.tasks.v2.CloudTasksClient;\nimport com.google.cloud.tasks.v2.CloudTasksSettings;\nimport io.grpc.ManagedChannelBuilder;\n\nCloudTasksSettings settings = CloudTasksSettings.newBuilder()\n .setCredentialsProvider(NoCredentialsProvider.create())\n .setTransportChannelProvider(\n InstantiatingGrpcChannelProvider.newBuilder()\n .setEndpoint(\"localhost:9090\")\n .setChannelConfigurator(ManagedChannelBuilder::usePlaintext)\n .build()\n )\n .build();\nCloudTasksClient client = CloudTasksClient.create(settings);\n```\n\n## The 'default' queue\n\nBy default, the emulator won't create a 'default' queue, however you can enable this\nby passing the fully-qualified name of the queue:\n\n```\ngcloud-tasks-emulator start --default-queue=projects/[PROJECT]/locations/[LOCATION]/queues/default\n```\n\n## Specifying a queue.yaml\n\nIf your project uses a queue.yaml file, you can create default queues by passing its path to the `--queue-yaml` argument.\n\nAdditionally, you'll likely want to pass `--queue-yaml-project` and `--queue-yaml-location` to generate the correct\nfully qualified queue names. These settings will otherwise default to `\"[PROJECT]\"` and `\"[LOCATION]\"` respectively.\n\n## Specifying a target\n\nTask queue needs to point at a service for outgoing requests. You can specify this with `--target-host` and `--target-port`\n\n## Testing\nRun:\n```\npython gcloud_tasks_emulator/tests.py\n```\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A stub emulator for the Google Cloud Tasks API",
"version": "0.6.1",
"project_urls": {
"Homepage": "https://gitlab.com/potato-oss/google-cloud/gcloud-tasks-emulator"
},
"split_keywords": [
"google cloud tasks",
" google app engine",
" gae",
" gcp"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "50cc382b6a9d20f04d3cd1269d362aeb168dda69e5ec10ed32d1db90d0d44390",
"md5": "0db27c693d46528964abc289216856af",
"sha256": "d0c015cb4fb58d18c0b7445f58f7f52250c76ba45fcccddd1bc94a024e114734"
},
"downloads": -1,
"filename": "gcloud_tasks_emulator-0.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0db27c693d46528964abc289216856af",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 17720,
"upload_time": "2024-07-03T11:54:14",
"upload_time_iso_8601": "2024-07-03T11:54:14.236391Z",
"url": "https://files.pythonhosted.org/packages/50/cc/382b6a9d20f04d3cd1269d362aeb168dda69e5ec10ed32d1db90d0d44390/gcloud_tasks_emulator-0.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d6d38c251543ef6bcb16a222d6166da7b341b5b4327ec80f7ecf59d9a70089be",
"md5": "55a9fec262362388e3924e8b8331ce18",
"sha256": "eadcd7be2c14145dfe41ea86ced55bf444f787adf25be5aa8491fb2f0ac37264"
},
"downloads": -1,
"filename": "gcloud-tasks-emulator-0.6.1.tar.gz",
"has_sig": false,
"md5_digest": "55a9fec262362388e3924e8b8331ce18",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 16593,
"upload_time": "2024-07-03T11:54:15",
"upload_time_iso_8601": "2024-07-03T11:54:15.991757Z",
"url": "https://files.pythonhosted.org/packages/d6/d3/8c251543ef6bcb16a222d6166da7b341b5b4327ec80f7ecf59d9a70089be/gcloud-tasks-emulator-0.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-03 11:54:15",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "potato-oss",
"gitlab_project": "google-cloud",
"lcname": "gcloud-tasks-emulator"
}