Metadata-Version: 2.4
Name: arnelify_broker
Version: 0.9.6
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: License :: OSI Approved :: MIT License
License-File: LICENSE
Summary: Multi-language broker with RPC and UMQT support.
Author: Taron Sarkisyan, Arnelify
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

<img src="https://static.wikia.nocookie.net/arnelify/images/c/c8/Arnelify-logo-2024.png/revision/latest?cb=20240701012515" style="width:336px;" alt="Arnelify Logo" />

![Arnelify Broker for Python](https://img.shields.io/badge/Arnelify%20Server%20for%20Python-0.9.6-yellow) ![Python](https://img.shields.io/badge/Python-3.13.5-blue) ![Nuitka](https://img.shields.io/badge/Nuitka-2.6.4-blue)

## 🚀 About

**Arnelify® Broker for Rust** — a multi-language broker with RPC and UMQT support.

All supported protocols:
| **#** | **Protocol** | **Transport** |
| - | - | - |
| 1 | TCP2 | UMQT |
| 2 | UDP | UMQT |

## 📋 Minimal Requirements
> Important: It's strongly recommended to use in a container that has been built from the gcc v15.2.0 image.
* CPU: Apple M1 / Intel Core i7 / AMD Ryzen 7
* OS: Debian 11 / MacOS 15 / Windows 10 with <a href="https://learn.microsoft.com/en-us/windows/wsl/install">WSL2</a>.
* RAM: 4 GB

## 📦 Installation
Run in terminal:
```bash
pip install arnelify_server
```
## 🎉 RPC
**RPC** - operates on top of the transport layer, enabling remote function and procedure calls.

### 📚 Examples

```python
from arnelify_broker import RPC
from arnelify_broker import BrokerCtx
from arnelify_broker import BrokerBytes
from arnelify_broker import RPCStream

import asyncio
from typing import Awaitable

async def main():

  rpc: RPC = RPC()
  async def rpc_logger(_level: str, message: str) -> Awaitable[None]:
    print("[Arnelify Broker]: " + message)

  rpc.logger(rpc_logger)

  async def rpc_action(ctx: BrokerCtx, bytes_: BrokerBytes, stream: RPCStream) -> None:
    await stream.push(ctx, bytes_)

  rpc.on("connect", rpc_action)

  message = "Hello World"
  
  json = { "message": message }
  buff: bytes | bytearray = message.encode('utf-8')
  
  ctx, bytes_ = await rpc.send("connect", json, buff, True)

  print(f"ctx: {ctx}")
  print(f"bytes: {bytes_}")

if __name__ == "__main__":
    asyncio.run(main())
```
## 🎉 UMQT
**UMQT (UDP Message Query Transport)** - is a universal WEB3-transport designed for flexible transport-layer communication, supporting two messaging mechanisms: TCP2 and datagrams.

### 📚 Configuration

| **Option** | **Description** |
| - | - |
| **BLOCK_SIZE_KB**| The size of the allocated memory used for processing large packets. |
| **CERT_PEM**| Path to the TLS cert-file in PEM format. |
| **COMPRESSION**| If this option is enabled, the server will use BROTLI compression if the client application supports it. This setting increases CPU resource consumption. The server will not use compression if the data size exceeds the value of **BLOCK_SIZE_KB**. |
| **KEY_PEM**| Path to the TLS private key-file in PEM format. |
| **PORT**| Defines which port the server will listen on. |
| **THREAD_LIMIT**| Defines the maximum number of threads that will handle requests. |

### 📚 Examples

```python
ffrom arnelify_broker import UMQT
from arnelify_broker import UMQTBytes
from arnelify_broker import UMQTOpts

import asyncio
from typing import Awaitable

async def main() -> Awaitable[None]:   

  umqt_opts: UMQTOpts = {
    "block_size_kb": 64,
    "cert_pem": "certs/cert.pem",
    "compression": True,
    "key_pem": "certs/key.pem",
    "port": 4433,
    "thread_limit": 4
  }

  umqt: UMQT = UMQT(umqt_opts)
  umqt.add_server("connect", "127.0.0.1", 4433)
  async def umqt_logger(_level: str, message: str) -> Awaitable[None]:
    print("[Arnelify Broker]: " + message)

  umqt.logger(umqt_logger)
  async def umqt_consumer(bytes_: UMQTBytes) -> Awaitable[None]:
    print("received: ", list(bytes_))

  umqt.on("connect", umqt_consumer)
  await umqt.start()

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

## ⚖️ MIT License
This software is licensed under the <a href="https://github.com/arnelify/arnelify-broker-python/blob/main/LICENSE">MIT License</a>. The original author's name, logo, and the original name of the software must be included in all copies or substantial portions of the software.

## 🛠️ Contributing
Join us to help improve this software, fix bugs or implement new functionality. Active participation will help keep the software up-to-date, reliable, and aligned with the needs of its users.

Run in terminal:
```bash
docker compose up -d --build
docker ps
docker exec -it <CONTAINER ID> bash
make install
source venv/bin/activate
make build
```
For RPC:
```bash
make test_rpc
```
For UMQT:
```bash
make test_umqt
```

## ⭐ Release Notes
Version 0.9.6 — a multi-language broker with RPC and UMQT support.

We are excited to introduce the Arnelify Broker for Python! Please note that this version is raw and still in active development.

Change log:

* UMQT support.
* Async Runtime & Multi-Threading.
* Block processing in "on-the-fly" mode.
* BROTLI compression (still in development).
* FFI, PYO3 and NEON support.
* Significant refactoring and optimizations.

Please use this version with caution, as it may contain bugs and unfinished features. We are actively working on improving and expanding the broker's capabilities, and we welcome your feedback and suggestions.

## 🔗 Links

* <a href="https://github.com/arnelify/arnelify-pod-cpp">Arnelify POD for C++</a>
* <a href="https://github.com/arnelify/arnelify-pod-node">Arnelify POD for NodeJS</a>
* <a href="https://github.com/arnelify/arnelify-pod-python">Arnelify POD for Python</a>
* <a href="https://github.com/arnelify/arnelify-pod-rust">Arnelify POD for Rust</a>
* <a href="https://github.com/arnelify/arnelify-react-native">Arnelify React Native</a>
