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.0a128.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.0a128-py3-none-any.whl
(151.7 kB
view details)
File details
Details for the file telepact-1.0.0a128.tar.gz.
File metadata
- Download URL: telepact-1.0.0a128.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 |
3500764072ed5e3ba6099cfda48d4f5579126b1be0b1f57683622c945f59f1d0
|
|
| MD5 |
750eb20745e9cc9e7e59eb4f7adb6e0e
|
|
| BLAKE2b-256 |
bb302a9b6c29fade2a3b3010f9583217bc9fad04541de281406c3692e6d99a59
|
File details
Details for the file telepact-1.0.0a128-py3-none-any.whl.
File metadata
- Download URL: telepact-1.0.0a128-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 |
7e781d61e6d10831b72ec1f50d14f0f95cffc1ee3c4cfa396b45ee42d8c796ee
|
|
| MD5 |
7ae010e763b2325e16f5e5ce2430d424
|
|
| BLAKE2b-256 |
7cbee6e9d3070fe0494a6576e57f1e25b6abe8a9a404c8471de1010b3ec69c0e
|