Renity Protocol Buffer#

PyPI Status Python Version License

Documentation Status Tests Codecov

pre-commit Black

Renity is an [Open Source] Python Object-Binary-Mapper(OBM) Binary Protocol Buffer that provides a way to rapidly define the de/serialization format of packets.

Installation 🔧#

You can install Renity via pip from PyPI:

$ pip install renity

✨ Features#

  • Improved throughput & reduced latency by reducing the data size transferred over the network

  • Serialization & Deserialization

  • Efficiency Compared to other formats like JSON & XML

  • Strict schema definition(s) for messages

  • Backward Compatible Schema(s)

  • Development effort is reduced with an easy-to-use interface that creates a Serialization Format from an Object Model.

Example 📏#


import requests
from rentity import Message, StringField, IntField

# Define Message Schema
>>> class CustomMessage(Message):
...     hello=StringField(default="World")
...     sentence=ListField(StringField(required=True),IntField())
...

# Create a message
>>> example = CustomMessage({"sentence": ["Number of Apples:", 2]})

# Deserialized Message
>>> example.message
{"type": "CustomMessage", "hello": "World", "sentence": ["Number of Apples:", 2]}

# Serialized Message
>>> example.bytes
b"\x97\x88\rCustomMessage\x03\x92\x88\x05World\x8a\x88\x16\x92\x88\x11Number of Apples:\x88\x02"

# Post Serialized Message
>>> requests.post(url='http://example.com/message',
...                data=example.bytes,
...                headers={'Content-Type': 'application/octet-stream'})
...

# GET Example
>>> res = requests.get('http://example.com/message')
>>> response = CustomMessage(res.content)
>>> response.message
{"type": "CustomMessage", "hello": "World", "sentence": ["Number of Apples:", 2]}

🔬 Tests#

It is recommended to set up Python 3.8, 3.9, 3.10 using [pyenv].

    # Install Poetry
    $ pip install poetry

    # Install Nox
    $ pip install nox

    # Install nox-poetry
    $ pip install nox-poetry

    # Install dependencies
    $ poetry install

    # Run Nox tests sessions
    $ nox --session

Contributing 🧠#

We welcome contributions of all types: from fixing typos to bug fixes to new features. For further questions about any of the below, please refer to the Contributor Guide. Reach out! We encourage all contributors to reach out for work reference’s. We’re here to help and are available for any inquiries regarding our contributors!

🎓 Interactive Practice#

Keep practicing so that your coding skills don’t get rusty.

  • Udemy

  • FreeCodeCamp

  • LeetCode

Usage#

Please see the Command-line Reference for details.

License#

Distributed under the terms of the Apache license, Renity is free and open source software.

Issues#

If you encounter any problems, please file an issue along with a detailed description.

Credits#

GooglePythonGodot EngineDjangoSteam