Skip to main content

A connector development framework adapted to Django

Project description

Overview

Django Aeotrade Connector is a framework that allows you to easily create your connector with Aeotrade OS.

Latest version: 0.1.0rc6

Quickstart

Install

pip install django-aeotrade-connector

After installing the package, you should add aeotrade_connector to django's INSTALLED_APPS

Usage

Initialize connector in django project

Before you initialize your connector. You must set AC_MANAGEMENT_ENDPOINT in django.settings.py, which is the endpoint of aeotrade connector management api.

python manage.py initconnector

This will create urls.py and dispatcher.py to your project

Create connector app

python manage.py startconnector <my_connector>

After executing this command, you should add my_connector to INSTALLED_APPS also. Then you will see a new django app named my_connector in your django project. In this app, you can see services.py and task.py python files. In services.py, you must implement some connector methods, which are inherited from ConnectorServices. and in task.py, you can define your connector tasks. those tasks will be registered when django setup.

Configuration

In app.py:

Before you start to run your connector, you must configure your connector in the app.py file. The configuration file is located in the my_connector/app.py file.

class MyConnectorConfig(AppConfig):
    name = 'my_connector'

    class Config:
        # required config
        connector = True
        connector_config_model = ConnectorBaseConfig(
            # required config
            label="my_first_connector",
            code="my_first_connector_code",
            mq_recv_model=MQManagerConfig(
                url="amqp://root:123456@localhost:5672/",
                exchange="test",
                queue="q_receive",
                pot=POT.Thread
            ),
            # optional config
            event_up_chain = True,
            files_up_chain = False,
            callback = some_function_name,
            callback_args = ['arg1', 'arg2'],
            callback_kwargs = {'key1': 'value1', 'key2': 'value2'},
            task_stop_when_error = False,
            auto_heartbeat = True,
            kw = {"extra_key": "extra_value"},
        )

In django.settings.py:

INSTALLED_APPS = [
    ...,
    'aeotrade_connector'
    'my_connector',
]

AC_MANAGEMENT_ENDPOINT = 'http://www.example.com:8000'

IS_TEST = False  # or True

# Redis is used to implement a distributed lock, ensuring that the scheduled task
# is executed only once even when multiple workers are started.
CACHES = {
    'default': {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": 'redis://localhost:6379/0',
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "CONNECTION_POOL_KWARGS": {"max_connections": 100, "password": "my_redis_password"}
        }
    }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_aeotrade_connector-0.1.0rc7.tar.gz (38.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_aeotrade_connector-0.1.0rc7-py3-none-any.whl (61.7 kB view details)

Uploaded Python 3

File details

Details for the file django_aeotrade_connector-0.1.0rc7.tar.gz.

File metadata

  • Download URL: django_aeotrade_connector-0.1.0rc7.tar.gz
  • Upload date:
  • Size: 38.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.7 Linux/5.14.0-570.39.1.el9_6.x86_64

File hashes

Hashes for django_aeotrade_connector-0.1.0rc7.tar.gz
Algorithm Hash digest
SHA256 007c802a0582567baf69bf07eeb5b912f1a49b0707354d7b2a76efe2505ca4ad
MD5 77b8079db5e1e675e7582299b2804f2e
BLAKE2b-256 14f807d8d9128fc0d9543ed3b7b9a63a54c8ae9b88ef66f219b6fc4b27d8f092

See more details on using hashes here.

File details

Details for the file django_aeotrade_connector-0.1.0rc7-py3-none-any.whl.

File metadata

File hashes

Hashes for django_aeotrade_connector-0.1.0rc7-py3-none-any.whl
Algorithm Hash digest
SHA256 431abd6d41b62308752b5039de56931c7faeb8cca12e1074346db1a6170be7dc
MD5 7d72530692ffae9b6c8a2660d61dda2b
BLAKE2b-256 a3f343c85ad0e47610d4a2f1263c464fc65982f8e625b21aff0c233eebf10329

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page