Library to create compute service with REST API and task queue
Project description
Compute Service
This is a Python library to create Compute Service with REST API and task queue.
Usage
To create new compute service one need to:
- Import packages
from pydantic import BaseModel
from compute_service import ComputeService
- Create service object with selected queue type:
service = ComputeService(queue='kafka')
kafka
and local
queue types are supported.
- Define model for input parameters and app factory:
class UserBase(BaseModel):
title: str
value: int
def create_app():
return service.create_app(UserBase)
- Define task processing callback and task handler:
def process(data):
print(f'Got data: {data}')
return {'ok': 'success'}
if __name__ == '__main__':
handler = service.create_handler(process)
handler.start()
- Start REST API:
uvicorn 'my_service:create_app'
- Start task handler:
python my_service.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
compute_service-0.0.1.tar.gz
(9.7 kB
view details)
Built Distribution
File details
Details for the file compute_service-0.0.1.tar.gz
.
File metadata
- Download URL: compute_service-0.0.1.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f22d95ee22a28280664b90d0a5c05e0ca23cf794338d13e3328b34d2e7e4653 |
|
MD5 | ba35caf1ab39037428a2054698fabd53 |
|
BLAKE2b-256 | a070697690867f45299a7415cac164499961fbac55a1f9e3f1fce361ac06baa2 |
File details
Details for the file compute_service-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: compute_service-0.0.1-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52e92940456f0a1688374d0eeacb37d0ee56587f188fd5cee0d0f38cff7f3a01 |
|
MD5 | fe00df7c95ee5d4b0674be937e09476c |
|
BLAKE2b-256 | 53e21bc2c3c87b1e9c6c66b7cb2159585467668ccffdb6d3c759223f659b8690 |