Данный протокол является протоколом RPC вида и служит для вызова процедур на удалённом сервере. Проект является исключительно учебным и не рекомендуется для реального использования.
Project description
Lite Procedure Transfer Protocol (LPTP)
Данный протокол является протоколом RPC вида и служит для вызова процедур на удалённом сервере. Проект является исключительно учебным и не рекомендуется для реального использования.
Установка
pip install lptp
Пример использования
Клиент
import asyncio
from lptp.client import LPTPClient
from lptp.types import AuthType
from lptp_procedures import ProcedureManager
async def main():
async with ProcedureManager(LPTPClient(
"127.0.0.1",
auth_type=AuthType.Key,
key="someKey"
)) as proc:
print(await proc.reverse_text("Привет Пацаны"))
asyncio.run(main())
Сервер
import logging
from lptp.server import LPTPServer, Manager
from lptp.types import AuthType
logging.basicConfig(level=logging.DEBUG)
server = LPTPServer(
"127.0.0.1",
auth_type = AuthType.Key,
key = "someKey"
)
manager = Manager()
@manager.procedure
async def reverse_text(text: str) -> str:
return text[::-1]
@manager.procedure
async def sum_numbers(a: int, b: int) -> int:
return a + b
@manager.sub_procedure(sum_numbers, 1)
async def sum_numbers_list(nums: list) -> int:
return sum(nums)
server.add_manager(manager)
server.generate_proc_file()
server.run_forever()
Важно
При запуске серверсайда необходимо вызвать метод generate_proc_file(), который создаст в текущей директории файл lptp_procedures.py с описанием всех процедур сервера. Работа клиентской стороны невозможна без этого файла.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lptp-1.0.1.tar.gz.
File metadata
- Download URL: lptp-1.0.1.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d98a3feb86a706626fde476efca9bea93b8c7991eb062ecd95754f67e23bd980
|
|
| MD5 |
81e078153a6278825625a4001ea34bf2
|
|
| BLAKE2b-256 |
08c833b5abae71c6576d06ac961b5d4aade1a6c9e875ae1a58dc6db007989514
|
File details
Details for the file lptp-1.0.1-py3-none-any.whl.
File metadata
- Download URL: lptp-1.0.1-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb87e6330462755a716c9869ff5f5427fece27c5d9df6cb08fd34d02658223a3
|
|
| MD5 |
0af0b1278c162a10901e8366fb8fc1c4
|
|
| BLAKE2b-256 |
02cd737bc2dd20c2ae6da9bce98a532db8fe50acb6034e5d2fa8212028c7a9a9
|