taskorbit


Nametaskorbit JSON
Version 0.1.6a0 PyPI version JSON
download
home_page
SummaryAsynchronous framework for managing asynchronous execution of independent tasks
upload_time2024-02-05 23:36:33
maintainer
docs_urlNone
author
requires_python>=3.10
license
keywords asyncio framework message brokers nats queue task-manager wrapper
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
    <img src="https://raw.githubusercontent.com/morington/taskorbit/main/docs/assets/images/taskorbit.png" alt="taskorbit-logo" height="200" />
</p>

<h1 align="center">TaskOrbit: Effortless Tasking</h1>
<h3 align="center">An asynchronous framework for Python with efficient task pooling that provides simple and flexible management of asynchronous execution of independent tasks.</h3>

<p align="center">
    <a href="#" target="_blank">
        <img alt="Status" src="https://img.shields.io/pypi/status/taskorbit.svg?style=flat-square">
    </a>
    <a href="#" target="_blank">
        <img alt="PyPI" src="https://img.shields.io/pypi/v/taskorbit.svg?style=flat-square">
    </a>
    <a href="#" target="_blank">
        <img alt="Python" src="https://img.shields.io/pypi/pyversions/taskorbit.svg">
    </a>
    <a href="#" target="_blank">
        <img alt="Python" src="https://img.shields.io/github/license/morington/taskorbit">
    </a>
    <a href="https://t.me/+0ih_O4_AkhlkMThi" target="_blank">
        <img alt="Python" src="https://img.shields.io/endpoint?url=https%3A%2F%2Ftelegram-badge-4mbpu8e0fit4.runkit.sh%2F%3Furl%3Dhttps%3A%2F%2Ft.me%2F%2B0ih_O4_AkhlkMThi&label=Community">
    </a>
</p>

# Taskorbit

<b>Taskorbit</b> is an asynchronous framework for managing a queue of asynchronous tasks. Inspired by ideas from [Celery](https://github.com/celery/celery), [Taskiq](https://github.com/taskiq-python/taskiq), [Propan](https://github.com/Lancetnik/Propan) and [Aiogram](https://github.com/aiogram/aiogram). This framework is based on message brokers. Currently, there is only support for [NATS JetStream](https://github.com/nats-io/nats.py). An expansion is planned for the future.

The framework allows you to create a powerful service for processing any tasks of any complexity in a short time. Entry is minimal, the development was oriented on beginners in the world of bot building and microservices development.

We can say simply - it is an improved version of Celery, Taskiq, Propan in the style of Aiogram. The differences are in specific requirements. It is important to choose technologies carefully to achieve optimal results.

<b>Documentation is currently being developed and will be available at: https://morington.github.io/taskorbit/</b>

# Install

Use the pip tool to install the framework:

```commandline
pip install taskorbit
```

Currently, with support for the NATS message broker only, variable installation with the broker is not supported. The library will install the necessary dependencies if required.

Taskorbit currently includes:
- <b>[magic_filter](https://github.com/aiogram/magic-filter)</b> - a handy way to enable dynamic signatures, created by the Aiogram developers.
- <b>[ormsgpack](https://github.com/aviramha/ormsgpack)</b> - a quick way to serialize data.
- <b>[nats-py](https://github.com/nats-io/nats.py)</b> - a standard message broker.

# Quick start

<i>You can read the full example on the repository page: https://github.com/morington/taskorbit/blob/main/examples/base_example.py.</i>

Create a broker object, distpecker object in your asynchronous function, load the configuration and start receiving messages!

```python
# For the example I will not use routers, the dispatcher inherits from routers so can also integrate handlers.
# DON'T DO THIS! USE taskorbit.dispatching.Router !
dp = Dispatcher(max_queue_size=5)


@dp.include_handler(F.metadata.type_event == "Test")
async def handler_test(metadata: Metadata) -> None:
    logger.info(f"Handler got the message! Task-{metadata.uuid}")


async def main():
    broker = await nats_broker(
        {
            "url": "nats://localhost:4222",
            "stream": "STREAM_NAME",
            "subject": "STREAM_NAME.SUBJECT",
            "durable": "DURABLE",
        }
    )
	
    await broker.include_dispatcher(dp)


if __name__ == "__main__":
    asyncio.run(main())
```

# Models metadata

<b>At the moment, development is underway on out-of-the-box custom message models. Please wait, the standard Metadata model is currently available for both service messages and task data messages:</b>

```python
class Message(BaseType):
    uuid: str
    type_event: str
    data: Optional[dict] = None


@dataclass
class ServiceMessage(BaseType):
    uuid: str
    command: Commands
```

# Sending messages

You can send messages to a thread using the pub method. Generate a unique UUID for each message to handle each shuffle:

```python
# Data messages for tasks:
uuid = uuid.uuid4().hex
await broker.pub({"uuid": uuid, "type_event": "TEST_CLASS", "data": {"some_data": 123}}))

# Service messages to work with tasks
# Service messages are not stored in the task pool. It needs to send the UUID it will work with
await broker.pub({"uuid": uuid, "command": Commands.GET_STATUS})
```

The framework also supports outer-middlewares and inner-middlewares. Middlewares fully support context managers throughout task processing.

<b>Currently, the Filters classes are disabled. Under testing.</b>

Please don't forget to refer to [EXAMPLES](https://github.com/morington/taskorbit/tree/main/examples) in the repository structure for help with the framework. Stable examples that have been tested are posted there.

# License:

Taskorbit is distributed under the MIT license. Details can be found in the [LICENSE](https://raw.githubusercontent.com/morington/taskorbit/main/LICENSE) file.



            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "taskorbit",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "asyncio,framework,message brokers,nats,queue,task-manager,wrapper",
    "author": "",
    "author_email": "Adam Morington <morington.mail@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/af/aa/6de1d446319412c0ba661ae3cec704494f30eb6ed18c8eb2881f691c8cb2/taskorbit-0.1.6a0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/morington/taskorbit/main/docs/assets/images/taskorbit.png\" alt=\"taskorbit-logo\" height=\"200\" />\n</p>\n\n<h1 align=\"center\">TaskOrbit: Effortless Tasking</h1>\n<h3 align=\"center\">An asynchronous framework for Python with efficient task pooling that provides simple and flexible management of asynchronous execution of independent tasks.</h3>\n\n<p align=\"center\">\n    <a href=\"#\" target=\"_blank\">\n        <img alt=\"Status\" src=\"https://img.shields.io/pypi/status/taskorbit.svg?style=flat-square\">\n    </a>\n    <a href=\"#\" target=\"_blank\">\n        <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/taskorbit.svg?style=flat-square\">\n    </a>\n    <a href=\"#\" target=\"_blank\">\n        <img alt=\"Python\" src=\"https://img.shields.io/pypi/pyversions/taskorbit.svg\">\n    </a>\n    <a href=\"#\" target=\"_blank\">\n        <img alt=\"Python\" src=\"https://img.shields.io/github/license/morington/taskorbit\">\n    </a>\n    <a href=\"https://t.me/+0ih_O4_AkhlkMThi\" target=\"_blank\">\n        <img alt=\"Python\" src=\"https://img.shields.io/endpoint?url=https%3A%2F%2Ftelegram-badge-4mbpu8e0fit4.runkit.sh%2F%3Furl%3Dhttps%3A%2F%2Ft.me%2F%2B0ih_O4_AkhlkMThi&label=Community\">\n    </a>\n</p>\n\n# Taskorbit\n\n<b>Taskorbit</b> is an asynchronous framework for managing a queue of asynchronous tasks. Inspired by ideas from [Celery](https://github.com/celery/celery), [Taskiq](https://github.com/taskiq-python/taskiq), [Propan](https://github.com/Lancetnik/Propan) and [Aiogram](https://github.com/aiogram/aiogram). This framework is based on message brokers. Currently, there is only support for [NATS JetStream](https://github.com/nats-io/nats.py). An expansion is planned for the future.\n\nThe framework allows you to create a powerful service for processing any tasks of any complexity in a short time. Entry is minimal, the development was oriented on beginners in the world of bot building and microservices development.\n\nWe can say simply - it is an improved version of Celery, Taskiq, Propan in the style of Aiogram. The differences are in specific requirements. It is important to choose technologies carefully to achieve optimal results.\n\n<b>Documentation is currently being developed and will be available at: https://morington.github.io/taskorbit/</b>\n\n# Install\n\nUse the pip tool to install the framework:\n\n```commandline\npip install taskorbit\n```\n\nCurrently, with support for the NATS message broker only, variable installation with the broker is not supported. The library will install the necessary dependencies if required.\n\nTaskorbit currently includes:\n- <b>[magic_filter](https://github.com/aiogram/magic-filter)</b> - a handy way to enable dynamic signatures, created by the Aiogram developers.\n- <b>[ormsgpack](https://github.com/aviramha/ormsgpack)</b> - a quick way to serialize data.\n- <b>[nats-py](https://github.com/nats-io/nats.py)</b> - a standard message broker.\n\n# Quick start\n\n<i>You can read the full example on the repository page: https://github.com/morington/taskorbit/blob/main/examples/base_example.py.</i>\n\nCreate a broker object, distpecker object in your asynchronous function, load the configuration and start receiving messages!\n\n```python\n# For the example I will not use routers, the dispatcher inherits from routers so can also integrate handlers.\n# DON'T DO THIS! USE taskorbit.dispatching.Router !\ndp = Dispatcher(max_queue_size=5)\n\n\n@dp.include_handler(F.metadata.type_event == \"Test\")\nasync def handler_test(metadata: Metadata) -> None:\n    logger.info(f\"Handler got the message! Task-{metadata.uuid}\")\n\n\nasync def main():\n    broker = await nats_broker(\n        {\n            \"url\": \"nats://localhost:4222\",\n            \"stream\": \"STREAM_NAME\",\n            \"subject\": \"STREAM_NAME.SUBJECT\",\n            \"durable\": \"DURABLE\",\n        }\n    )\n\t\n    await broker.include_dispatcher(dp)\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n# Models metadata\n\n<b>At the moment, development is underway on out-of-the-box custom message models. Please wait, the standard Metadata model is currently available for both service messages and task data messages:</b>\n\n```python\nclass Message(BaseType):\n    uuid: str\n    type_event: str\n    data: Optional[dict] = None\n\n\n@dataclass\nclass ServiceMessage(BaseType):\n    uuid: str\n    command: Commands\n```\n\n# Sending messages\n\nYou can send messages to a thread using the pub method. Generate a unique UUID for each message to handle each shuffle:\n\n```python\n# Data messages for tasks:\nuuid = uuid.uuid4().hex\nawait broker.pub({\"uuid\": uuid, \"type_event\": \"TEST_CLASS\", \"data\": {\"some_data\": 123}}))\n\n# Service messages to work with tasks\n# Service messages are not stored in the task pool. It needs to send the UUID it will work with\nawait broker.pub({\"uuid\": uuid, \"command\": Commands.GET_STATUS})\n```\n\nThe framework also supports outer-middlewares and inner-middlewares. Middlewares fully support context managers throughout task processing.\n\n<b>Currently, the Filters classes are disabled. Under testing.</b>\n\nPlease don't forget to refer to [EXAMPLES](https://github.com/morington/taskorbit/tree/main/examples) in the repository structure for help with the framework. Stable examples that have been tested are posted there.\n\n# License:\n\nTaskorbit is distributed under the MIT license. Details can be found in the [LICENSE](https://raw.githubusercontent.com/morington/taskorbit/main/LICENSE) file.\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Asynchronous framework for managing asynchronous execution of independent tasks",
    "version": "0.1.6a0",
    "project_urls": {
        "Documentation": "https://morington.github.io/taskorbit/",
        "Repository": "https://github.com/morington/taskorbit/",
        "Telegram community": "https://t.me/+0ih_O4_AkhlkMThi"
    },
    "split_keywords": [
        "asyncio",
        "framework",
        "message brokers",
        "nats",
        "queue",
        "task-manager",
        "wrapper"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "069a0b6a005b9153b7076e27d8feb9c57048f349580d2e1c1046a76b64db8d86",
                "md5": "34c902b886cd402eef7d88d6159d31fd",
                "sha256": "122f3ec358bfe73a547c6b3e8ec104df4c77c602e465530827a6e44fc09de8ab"
            },
            "downloads": -1,
            "filename": "taskorbit-0.1.6a0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "34c902b886cd402eef7d88d6159d31fd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 15072,
            "upload_time": "2024-02-05T23:36:31",
            "upload_time_iso_8601": "2024-02-05T23:36:31.130217Z",
            "url": "https://files.pythonhosted.org/packages/06/9a/0b6a005b9153b7076e27d8feb9c57048f349580d2e1c1046a76b64db8d86/taskorbit-0.1.6a0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "afaa6de1d446319412c0ba661ae3cec704494f30eb6ed18c8eb2881f691c8cb2",
                "md5": "44fa4b3c6d56af3e88b87e5d416107e0",
                "sha256": "b470c851667db6d1a8d1ec61a1373fcb45d902f61250d2c10d8daab764f13019"
            },
            "downloads": -1,
            "filename": "taskorbit-0.1.6a0.tar.gz",
            "has_sig": false,
            "md5_digest": "44fa4b3c6d56af3e88b87e5d416107e0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 172096,
            "upload_time": "2024-02-05T23:36:33",
            "upload_time_iso_8601": "2024-02-05T23:36:33.622668Z",
            "url": "https://files.pythonhosted.org/packages/af/aa/6de1d446319412c0ba661ae3cec704494f30eb6ed18c8eb2881f691c8cb2/taskorbit-0.1.6a0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-05 23:36:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "morington",
    "github_project": "taskorbit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "taskorbit"
}
        
Elapsed time: 0.46264s