{"id":19748700,"url":"https://github.com/doitintl/cloud-tasks-in-process-emulator","last_synced_at":"2025-04-30T08:33:45.992Z","repository":{"id":44329205,"uuid":"275617538","full_name":"doitintl/Cloud-Tasks-In-Process-Emulator","owner":"doitintl","description":"Google doesn't offer an emulator for the Cloud Tasks API, as it does for Datastore or PubSub. This project answers that need with a single short Python module intended to be copied to your codebase.","archived":false,"fork":false,"pushed_at":"2023-05-01T21:42:59.000Z","size":46,"stargazers_count":18,"open_issues_count":2,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-05-04T00:05:36.551Z","etag":null,"topics":["cloud-tasks","emulator","google-cloud-platform"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doitintl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-28T15:49:45.000Z","updated_at":"2024-03-19T22:24:52.000Z","dependencies_parsed_at":"2022-08-28T17:20:27.370Z","dependency_job_id":null,"html_url":"https://github.com/doitintl/Cloud-Tasks-In-Process-Emulator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doitintl%2FCloud-Tasks-In-Process-Emulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doitintl%2FCloud-Tasks-In-Process-Emulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doitintl%2FCloud-Tasks-In-Process-Emulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doitintl%2FCloud-Tasks-In-Process-Emulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doitintl","download_url":"https://codeload.github.com/doitintl/Cloud-Tasks-In-Process-Emulator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224203949,"owners_count":17273021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloud-tasks","emulator","google-cloud-platform"],"created_at":"2024-11-12T02:23:05.599Z","updated_at":"2024-11-12T02:23:06.065Z","avatar_url":"https://github.com/doitintl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# In-Process Simple Emulator for Google Cloud Tasks\nGoogle [doesn't](https://cloud.google.com/tasks/docs/migrating#features_in_task_queues_not_yet_available_via)\n[offer](https://issuetracker.google.com/issues/133627244)\nan emulator for the Cloud Tasks API,  as it does for Datastore or PubSub. This project answers that need.\n\n# Article\nSee the article at the [DoiT blog](https://blog.doit-intl.com/looking-for-an-emulator-for-cloud-tasks-45f0ae2c67b5?source=friends_link\u0026sk=05f7c4f7c0c63c2043cd53690ced3df4) \nfor full details.\n\n# Usage\n\nTo use this emulator\n- Copy `emulator.py` into your codebase. \n- Create an `Emulator` object, passing a callback function, which will receive\nthe payloads of the tasks that you create. \n- To send tasks, call the method `Emulator.create_task`. You can choose the queue and the scheduled delivery time.\n\n# Persistence \nThe implementation is designed to be copied into your codebase as a single file, and so is kept very simple.\nQueue stage is kept in memory. To support restarts during debugging -- which includes automated reload in Flask,\nwhenever you change code -- state is stored to disk on exit, then reloaded on initialization. \nIf you don't want that, pass `hibernation=False` to the  `Emulator` constructor.\n\n# Usage Example\n- As a usage example, run `local_server.py`. \n- This example is a trivial webapp: Browse to [http://127.0.0.1:8080](http://127.0.0.1:8080) \n(or just click the link \nin the console) and a task will be created (see `main.py`). \n- The task will be handled, on schedule, three seconds later.\n- The example handler \"processes\" the task simply by upper-casing it and printing it.\n- This example shows how to keep the Emulator codebase separate from the production codebase. \n  - In `local_server.py` used in development, we inject an `Emulator`.\n  - In contrast , in a deployed server, where no such `Emulator` is injected, a new `CloudTasksAccessor` is created that invokes\n  the real Cloud Tasks API, keeping the server code (`main.py`) clear of any emulator code.\n  - For full separation, you could even omit  `emulator.py` in deployment. (Though there is no harm if you leave it in.)\n- To deploy this example  app, run ` gcloud -q app deploy app.yaml`\n\n    \n# Scope of functionality\n  - This project supports the functionality that you typically use in development: Creating\n  a task, and then handling the task in a callback.\n  - Some unsupported features:\n    - Queue management, including creating, deleting, purging, pausing and resuming queues.\n    (When you add a task, a queue is automatically created if not yet present for that task.)\n    - Configuration of rate limits and retries.\n    - Deduplication and deletion of tasks.\n  - These features could be added, but:\n    -  A simpler codebase is better for debuJgging. The whole emulator is  under 120 lines and easy to understand. \n     For fuller functionality and more realistic testing, I would use the real Cloud Tasks, in a deployed system.\n  - If you would like improvements, please submit Pull Requests or Issues.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoitintl%2Fcloud-tasks-in-process-emulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoitintl%2Fcloud-tasks-in-process-emulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoitintl%2Fcloud-tasks-in-process-emulator/lists"}