The Python Telepact library
Project description
Telepact
Installation
pip install telepact
Usage
API:
[
{
"fn.greet": {
"subject": "string"
},
"->": {
"Ok_": {
"message": "string"
}
}
}
]
Server:
files = TelepactSchemaFiles('/directory/containing/api/files')
schema = TelepactSchema.from_file_json_map(files.filenames_to_json)
async def handler(request_message: 'Message') -> 'Message':
function_name = request_message.body.keys[0]
arguments = request_message.body[function_name]
if function_name == 'fn.greet':
subject = arguments['subject']
return Message({}, {'Ok_': {'message': f'Hello {subject}!'}})
raise Exception('Function not found')
options = Server.Options()
server = Server(schema, handler, options)
# Wire up request/response bytes from your transport of choice
response_bytes = server.process(request_bytes)
Client:
async def adapter(m: Message, s: Serializer) -> Message:
request_bytes = s.serialize(m)
# Wire up request/response bytes to your transport of choice
return s.deserialize(response_bytes)
options = Client.Options()
client = Client(adapter, options)
For more concrete usage examples, see the tests.
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
telepact-1.0.0a122.tar.gz
(44.5 kB
view details)
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
telepact-1.0.0a122-py3-none-any.whl
(151.7 kB
view details)
File details
Details for the file telepact-1.0.0a122.tar.gz.
File metadata
- Download URL: telepact-1.0.0a122.tar.gz
- Upload date:
- Size: 44.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32b90f99206362953134a6faa2a227f676dd53e100125163221e552c55d5f560
|
|
| MD5 |
3380c1d8f7824e266880835fd8961285
|
|
| BLAKE2b-256 |
5beb3da68ed324ef999f1d0500f3e971ea5452751bff505dff4805cfa7e0fe63
|
File details
Details for the file telepact-1.0.0a122-py3-none-any.whl.
File metadata
- Download URL: telepact-1.0.0a122-py3-none-any.whl
- Upload date:
- Size: 151.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
725ae10d3f8698e36830b81dfc9ce4cb2a2b9acc82de93d8291d9a1cf2b1589f
|
|
| MD5 |
fc655c8a4614af30fce29a8549654c0b
|
|
| BLAKE2b-256 |
f6e8ca78dff45ffaf0713da5775ab1296a6ab4424fbff5322b9db697785bc03f
|