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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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