All Projects → Intility → metroid

Intility / metroid

Licence: MIT license
Metroid - Metro for Django (An async Azure Service Bus receiver, triggering task in Celery/RQ)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to metroid

django-telegram-bot
My sexy Django + python-telegram-bot + Celery + Redis + Postgres + Dokku + GitHub Actions template
Stars: ✭ 470 (+1640.74%)
Mutual labels:  celery
cell
actor framework for Kombu
Stars: ✭ 73 (+170.37%)
Mutual labels:  celery
guane-intern-fastapi
FastAPI-PostgreSQL-Celery-RabbitMQ-Redis bakcend with Docker containerization
Stars: ✭ 54 (+100%)
Mutual labels:  celery
FastAPI Tortoise template
FastAPI - Tortoise ORM - Celery - Docker template
Stars: ✭ 144 (+433.33%)
Mutual labels:  celery
myblog
An Open Source Multi-user Blog System that Powered by Flask.
Stars: ✭ 19 (-29.63%)
Mutual labels:  celery
django-step-by-step
A Django + Vue reference project that focuses on developer tooling and CI/CD + IaC
Stars: ✭ 86 (+218.52%)
Mutual labels:  celery
celery-monitor
The celery monitor app was written by Django.
Stars: ✭ 92 (+240.74%)
Mutual labels:  celery
docker-compose-django-postgresql-redis-example
Django + Postgres + Redis + Celery + Celery Beat + WebSocket server
Stars: ✭ 158 (+485.19%)
Mutual labels:  celery
Text2Video
WriteMyVideo's purpose is to help people create videos quickly and easily by simply typing out the video’s script and a description of images to include in the video.
Stars: ✭ 19 (-29.63%)
Mutual labels:  rq
python react blog back end
Redis Celery Fabric Gunicorn Personal Blog
Stars: ✭ 12 (-55.56%)
Mutual labels:  celery
celery-prometheus-exporter
Celery prometheus metrics exporter revisited
Stars: ✭ 25 (-7.41%)
Mutual labels:  celery
azure-event-driven-data-pipeline
Building event-driven data ingestion pipelines in Azure
Stars: ✭ 13 (-51.85%)
Mutual labels:  azure-service-bus
DeadPool
该项目是一个使用celery作为主体框架的爬虫应用,能够灵活的添加爬虫任务,并且同时运行多站点的爬虫工作,所有组件都能够原生支持规模并发和分布式,加上celery原生的分布式调用,实现大规模并发。
Stars: ✭ 38 (+40.74%)
Mutual labels:  celery
celery-batches
Celery Batches allows processing of multiple Celery task requests together
Stars: ✭ 58 (+114.81%)
Mutual labels:  celery
docker-flask-example
A production ready example Flask app that's using Docker and Docker Compose.
Stars: ✭ 311 (+1051.85%)
Mutual labels:  celery
dispatcher
Dispatcher is an asynchronous task queue/job queue based on distributed message passing.
Stars: ✭ 60 (+122.22%)
Mutual labels:  celery
fastapi
基于Fastapi开发,集成Celery-redis分布式任务队列、JWT 用户系统、ElasticSearch和encode orm的基础项目模板,大家可以根据自己的需求在本模板上进行修改
Stars: ✭ 75 (+177.78%)
Mutual labels:  celery
Final-Senior-Year-Project-
My College Final(Senior) Year Project
Stars: ✭ 98 (+262.96%)
Mutual labels:  celery
fastapi-celery-redis-rabbitmq
A simple docker-compose app for orchestrating a fastapi application, a celery queue with rabbitmq(broker) and redis(backend)
Stars: ✭ 81 (+200%)
Mutual labels:  celery
funboost
pip install funboost,python全功能分布式函数调度框架,。支持python所有类型的并发模式和全球一切知名消息队列中间件,python函数加速器,框架包罗万象,一统编程思维,兼容50% python编程业务场景,适用范围广。只需要一行代码即可分布式执行python一切函数。旧名字是function_scheduling_distributed_framework
Stars: ✭ 351 (+1200%)
Mutual labels:  celery


Metroid

Subscribe, act, publish.

Python version Django version Celery version ServiceBus version Django GUID version

Codecov Pre-commit Black mypy isort

Metroid - Metro for Django

This app is intended to streamline integration with Metro for all Django+Celery users by:

  • Asynchronous handling of subscriptions and messages with one command
  • Execute Celery tasks based on message topics, defined in settings.py
  • Retry failed tasks through your admin dashboard when using the MetroidTask base

Overview

  • python >= 3.8
  • django >= 3.1.1 - For asgiref, settings
  • django-guid >= 3.2.0 - Storing correlation IDs for failed tasks in the database, making debugging easy
  • Choose one:
    • celery >= 5.0.0 - Execute tasks based on a subject
    • rq >= 2.4.1 - Execute tasks based on a subject

Implementation

The python manage.py metroid app is fully asynchronous, and has no blocking code. It utilizes Celery to execute tasks.

It works by:

  1. Going through all your configured subscriptions and start a new async connection for each one of them
  2. Metro sends messages on the subscriptions
  3. This app filters out messages matching subjects you have defined, and queues a celery task to execute the function as specified for that subject
    3.1. If no task is found for that subject, the message is marked as complete
  4. The message is marked as complete after the Celery task has successfully been queued
  5. If the task is failed, an entry is automatically created in your database
  6. All failed tasks can be retried manually through the admin dashboard

Configure and install this package

Note For a complete example, have a look in demoproj/settings.py.

  1. Create a METROID key in settings.py with all your subscriptions and handlers. Example settings:
METROID = {
    'subscriptions': [
        {
            'topic_name': 'metro-demo',
            'subscription_name': 'sub-metrodemo-metrodemoerfett',
            'connection_string': config('CONNECTION_STRING_METRO_DEMO', None),
            'handlers': [
               {
                  'subject': 'MetroDemo/Type/GeekJokes',
                  'regex': False,
                  'handler_function': 'demoproj.demoapp.services.my_func'
                }
            ],
        },
    ],
   'worker_type': 'celery', # default
}

The handler_function is defined by providing the full dotted path as a string. For example,from demoproj.demoapp.services import my_func is provided as 'demoproj.demoapp.services.my_func'.

The handlers subject can be a regular expression or a string. If a regular expression is provided, the variable regex must be set to True. Example:

'handlers': [{'subject': r'^MetroDemo/Type/.*$','regex':True,'handler_function': my_func}],
  1. Configure Django-GUID by adding the app to your installed apps, to your middlewares and configuring logging as described here. Make sure you enable the CeleryIntegration:
from django_guid.integrations import CeleryIntegration

DJANGO_GUID = {
    'INTEGRATIONS': [
        CeleryIntegration(
            use_django_logging=True,
            log_parent=True,
        )
    ],
}

Creating your own handler functions

Your functions will be called with keyword arguments for

message, topic_name, subscription_name and subject. You function should in other words look something like this:

Celery
@app.task(base=MetroidTask)
def my_func(*, message: dict, topic_name: str, subscription_name: str, subject: str) -> None:
rq
def my_func(*, message: dict, topic_name: str, subscription_name: str, subject: str) -> None:

Running the project

  1. Ensure you have redis running:
docker-compose up
  1. Run migrations
python manage.py migrate
  1. Create an admin account
python manage.py createsuperuser
  1. Start a worker:
celery -A demoproj worker -l info
  1. Run the subscriber:
python manage.py metroid
  1. Send messages to Metro. Example code can be found in demoproj/demoapp/services.py
  2. Run the webserver:
python manage.py runserver 8000
  1. See failed messages under http://localhost:8080/admin

To contribute, please see CONTRIBUTING.md

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].