A library for developing applications with a message-based protocol on top of TCP based on asyncio.Opens the possibility of adding controllers that are responsible for specific commands, the ability to define and validate command arguments.
-
First, you need to create an instance of the App class
import asyncio from asyncio_tcp_messages import App app = App() #Your code if __name__ == '__main__': asyncio.run(app.run()) -
Here are some usage examples. You can use pydantic BaseModel subclasses for data validation.
import asyncio from asyncio_tcp_messages import App import pydantic app = App() class Person(pydantic.BaseModel): name: str = pydantic.Field(..., min_length=2, max_length=250, description="The person's name must be at least 2 " "and at most 250 characters") age: int = pydantic.Field(..., ge=0, lt=200, description="The person's age must be greater or equal to zero " "and lesser than 250") funs: list[str] = pydantic.Field(default_factory=list, title="The activities person likes to do") salary: int = pydantic.Field(None, gt=0, description="The person's salary must be greater than zero") def __str__(self) -> str: return f'{self.name} is {self.age} years old with {self.salary}$ salary and favourite activities: {self.funs}' @app.command(name='sum') async def custom_sum(user_id: int, arg1: int, arg2: int) -> str: return str(arg1 + arg2) @app.command() async def add_person(user_id: int, person: Person): people.append(person) @app.command() async def get_person(user_id: int, name: str) -> str: return '\n'.join(str(person) for person in people if person.name == name) if __name__ == '__main__': asyncio.run(app.run())
Metadata
Release files for asyncio-tcp-messages 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| asyncio_tcp_messages-0.1.4.tar.gz | 4.2 kB | Without provenance | Details for asyncio_tcp_messages-0.1.4.tar.gz |
Release files / asyncio_tcp_messages-0.1.4.tar.gz
| Download URL | asyncio_tcp_messages-0.1.4.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f467212594d9ee6c3993f6e0f54696ebe3a42d25ba888e3e388915b549a1ea5f
|
|
BLAKE2b-256 checksum How to use checksums |
7259832bce850358551054bf02d73d80d9ea62486fc6e31fa135ff3700a735fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.0 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.6
|
Security for asyncio-tcp-messages 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.