Skip to main content

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:

  1. Import packages
from pydantic import BaseModel
from compute_service import ComputeService
  1. Create service object with selected queue type:
service = ComputeService(queue='kafka')

kafka and local queue types are supported.

  1. Define model for input parameters and app factory:
class UserBase(BaseModel):
    title: str
    value: int

def create_app():
    return service.create_app(UserBase)
  1. 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()
  1. Start REST API:
uvicorn 'my_service:create_app'
  1. Start task handler:
python my_service.py

Project details


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)

Uploaded Source

Built Distribution

compute_service-0.0.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

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

Hashes for compute_service-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3f22d95ee22a28280664b90d0a5c05e0ca23cf794338d13e3328b34d2e7e4653
MD5 ba35caf1ab39037428a2054698fabd53
BLAKE2b-256 a070697690867f45299a7415cac164499961fbac55a1f9e3f1fce361ac06baa2

See more details on using hashes here.

File details

Details for the file compute_service-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for compute_service-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 52e92940456f0a1688374d0eeacb37d0ee56587f188fd5cee0d0f38cff7f3a01
MD5 fe00df7c95ee5d4b0674be937e09476c
BLAKE2b-256 53e21bc2c3c87b1e9c6c66b7cb2159585467668ccffdb6d3c759223f659b8690

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page