All Projects → GeorgeLubaretsi → Django Cloud Tasks

GeorgeLubaretsi / Django Cloud Tasks

Licence: mit
Integrate Google Cloud Tasks with Django

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Django Cloud Tasks

Google-Cloud-Study-Jams
Resources for 30 Days of Google Cloud program workshops and events conducted by GDSC VJTI
Stars: ✭ 13 (-51.85%)
Mutual labels:  google-cloud, google-cloud-platform
pipeline-editor
Cloud Pipelines Editor is a web app that allows the users to build and run Machine Learning pipelines without having to set up development environment.
Stars: ✭ 22 (-18.52%)
Mutual labels:  google-cloud, google-cloud-platform
appengine-java-standard
Google App Engine Standard Java runtime: Prod runtime, local devappserver, Cloud SDK Java components, GAE APIs, and GAE API emulators.
Stars: ✭ 141 (+422.22%)
Mutual labels:  google-cloud, google-cloud-platform
monolog-google-cloud-json-formatter
A Monolog extension for formatting log entries for Google Cloud Logging
Stars: ✭ 15 (-44.44%)
Mutual labels:  google-cloud, google-cloud-platform
Laravel Google Cloud Storage
A Google Cloud Storage filesystem for Laravel
Stars: ✭ 415 (+1437.04%)
Mutual labels:  google-cloud, google-cloud-platform
argon
Campaign Manager 360 and Display & Video 360 Reports to BigQuery connector
Stars: ✭ 31 (+14.81%)
Mutual labels:  google-cloud, google-cloud-platform
ob google-bigquery
This service is meant to simplify running Google Cloud operations, especially BigQuery tasks. This means you do not have to worry about installation, configuration or ongoing maintenance related to an SDK environment. This can be helpful to those who would prefer to not to be responsible for those activities.
Stars: ✭ 43 (+59.26%)
Mutual labels:  google-cloud, google-cloud-platform
cloud-cardboard-viewer
Build a Node.js & Angular 2 Web App using Google Cloud Platform
Stars: ✭ 23 (-14.81%)
Mutual labels:  google-cloud, google-cloud-platform
All About Programming
Everything about programming!!
Stars: ✭ 314 (+1062.96%)
Mutual labels:  google-cloud, google-cloud-platform
gcp-firewall-enforcer
A toolbox to enforce firewall rules across multiple GCP projects.
Stars: ✭ 77 (+185.19%)
Mutual labels:  google-cloud, google-cloud-platform
Cloud-Service-Providers-Free-Tier-Overview
Comparing the free tier offers of the major cloud providers like AWS, Azure, GCP, Oracle etc.
Stars: ✭ 226 (+737.04%)
Mutual labels:  google-cloud, google-cloud-platform
Django Todo
A multi-user, multi-group todo/ticketing system for Django projects. Includes CSV import and integrated mail tracking.
Stars: ✭ 592 (+2092.59%)
Mutual labels:  tasks, django
iris3
An upgraded and improved version of the Iris automatic GCP-labeling project
Stars: ✭ 38 (+40.74%)
Mutual labels:  google-cloud, google-cloud-platform
notionproxy
Notion as a web site, inspired by react-notion-x.
Stars: ✭ 24 (-11.11%)
Mutual labels:  google-cloud, google-cloud-platform
emulator-tools
Google Cloud BigTable and PubSub emulator tools to make development a breeze
Stars: ✭ 16 (-40.74%)
Mutual labels:  google-cloud, google-cloud-platform
restme
Template to bootstrap a fully functional, multi-region, REST service on GCP with a developer release pipeline.
Stars: ✭ 19 (-29.63%)
Mutual labels:  google-cloud, google-cloud-platform
Php-Google-Vision-Api
Google Vision Api for PHP (https://cloud.google.com/vision/)
Stars: ✭ 61 (+125.93%)
Mutual labels:  google-cloud, google-cloud-platform
zorya
Google Cloud Instance Scheduler helping to reduce costs by 60% on average for non-production environments.
Stars: ✭ 127 (+370.37%)
Mutual labels:  google-cloud, google-cloud-platform
rowy
Open-source Airtable-like experience for your database (Firestore) with GCP's scalability. Build any automation or cloud functions for your product. ⚡️✨
Stars: ✭ 2,676 (+9811.11%)
Mutual labels:  google-cloud, google-cloud-platform
Cloud Functions Go
Unofficial Native Go Runtime for Google Cloud Functions
Stars: ✭ 427 (+1481.48%)
Mutual labels:  google-cloud, google-cloud-platform

============================ Django Cloud Tasks

Integrate Google Cloud Tasks <https://goo.gl/Ya0AZd>_ with Django.

Package provides easy to use decorator to create task handlers.

App looks for tasks in cloud_tasks.py files in your installed applications and auto-registers them.

Package is in early alpha and it does not have any real security at the moment. You need to authorize requests coming to your instances yourself.

Prerequisites

  • Django 1.8+
  • Python 3.4, 3.5, 3.6

Dependencies

  • google-api-python-client <https://pypi.python.org/pypi/google-api-python-client/>_

Documentation

TODO

Installation

(1) Install latest version from Github (PyPy package will be available as soon as stable version is released):

.. code-block:: sh

    pip install -e [email protected]:GeorgeLubaretsi/django-cloud-tasks.git#egg=django_cloud_tasks

(2) Add django_cloud_tasks to INSTALLED_APPS:

.. code-block:: python

    INSTALLED_APPS = (
        # ...
        'django_cloud_tasks',
        # ...
    )

(3) Add configuration to your settings

.. code-block:: python

    DJANGO_CLOUD_TASKS={
        'project_location_name': 'projects/{project_name}/locations/us-central1',
        'task_handler_root_url': '/_tasks/',
    },

    # This setting allows you to debug your cloud tasks by running actual task handler function locally
    # instead of sending them to the task queue. Default: False
    DJANGO_CLOUD_TASKS_EXECUTE_LOCALLY = False

    # If False, running `.execute()` on remote task will simply log the task data instead of adding it to
    # the queue. Useful for debugging. Default: True
    DJANGO_CLOUD_TASKS_BLOCK_REMOTE_TASKS = False

(4) Add cloud task views to your urls.py (must resolve to the same url as task_handler_root_url)

.. code-block:: python

    # urls.py
    # ...
    from django.urls import path, include
    from django_cloud_tasks import urls as dct_urls

    urlpatterns = [
        # ...
        path('_tasks/', include(dct_urls)),
    ]

Quick start

Simply import the task decorator and define the task inside cloud_tasks.py in your app. First parameter should always be request which is populated after task is executed by Cloud Task service.

You can get actual request coming from Cloud Task service by accessing request.request in your task body and additional attributes such as: ``request.task_id,request.request_headers```

.. code-block:: python

# cloud_tasks.py
# ...
from django_cloud_tasks.decorators import task

@task(queue='default')
def example_task(request, p1, p2):
    print(p1, p2)
    print(request.task_id)

Pushing the task to the queue:

.. code-block:: python

from my_app.cloud_tasks import example_task

example_task(p1='1', p2='2').execute()

Pushing remote task to the queue (when task handler is defined elsewhere):

.. code-block:: python

from django_cloud_tasks import remote_task
from django_cloud_tasks import batch_execute

example_task = remote_task(queue='my-queue', handler='remote_app.cloud_tasks.example_task'):
payload_1 = example_task(payload={'p1': 1, 'p2': '2'})
payload_2 = example_task(payload={'p1': 2, 'p2': '3'})

# Execute in batch:
batch_execute([payload_1, payload_2])

# Or one by one:
payload_1.execute()
payload_2.execute()

You can also send tasks in batch if latency is an issue and you have to send many small tasks to the queue (limited to 1000 at a time):

.. code-block:: python

from my_app.cloud_tasks import example_task
from django_cloud_tasks import batch_execute

tasks = []
for i in range(0, 420):
    task = example_task(p1=i, p2=i)
    tasks.append(task)

batch_execute(tasks)

It is also possible to run an actual function using run method of CloudTaskWrapper object instance that is returned after task is called (this can be useful for debugging):

.. code-block:: python

task = example_task(p1=i, p2=i)
task.run()
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].