Otter is framework for creating microservices in Flask like fassion using RPC communication via message queue.

Related tags

Web Frameworksotter
Overview

Otter

Framework for microservices.

PyPI version PyPI license Maintenance

Overview

Otter is framework for creating microservices in Flask like fassion using RPC communication via message queue. Its built in top of kiwiPy library.

Application

Simple Otter application looks liks this.

from otter import Otter
import hashlib
import time

app = Otter()

@app.add_broadcast(["message.*"])
def example_broadcast(comm, body, sender, subject, correlation_id):
    print(f"Received {body}")

@app.add_task("example.task")
def example_task(comm, delay):
    time.sleep(delay)
    print(f"Done waiting {delay} seconds")

@app.add_rpc("example.hash")
def example_hash(comm, data):
    return {
        "result": hashlib.sha256(
            data.encode("utf-8")
        ).hexdigest()
    }

app.run("amqp://guest:[email protected]/", debug=True)

Client

You can communicate with Otter application using Client.

from otter import Client

client = Client("amqp://guest:[email protected]/")

if client.comm:
    # Broadcast message to anyone who listens
    client.broadcast("otter", subject="message.send")

    # Send task to remote worker
    client.task("example.task", 5)

    # Send rpc request to hash "otter" and wait for the result
    data = client.rpc("example.hash", "otter").result()

client.close()

Blueprints

You can use Flask like blueprints in order to organize and split your application into different modules.

from otter import Blueprint

blueprint = Blueprint()

@blueprint.add_rpc("hello.world")
def example_hash(comm, data):
    return {"result": "Hello world from blueprint!"}

After that blueprint can be initialized using register_blueprint method.

app.register_blueprint(blueprint)

Decorators

In most cases you will use JSON to communicate between your microservices, thats why Otter has built in decorator @use_args which uses Marshmallow for data validation.

from marshmallow import fields, validate
from otter.decorators import use_args

login_args = {
    "password": fields.Str(required=True, validate=validate.Length(min=8)),
    "email": fields.Email(required=True)
}

@app.add_rpc("auth.login")
@use_args(login_args)
def login(comm, data):
    return {"args": data}

Foreword

This is experimental software, any contributions are welcome!

Owner
Volodymyr Biloshytskyi
Blockchain Developer | Freelancer | Lazy Ass ∠( ᐛ 」∠)
Volodymyr Biloshytskyi
Online Boutique is a cloud-native microservices demo application

Online Boutique is a cloud-native microservices demo application. Online Boutique consists of a 10-tier microservices application. The application is

Matt Reider 1 Oct 22, 2021
A simple todo app using flask and sqlachemy

TODO app This is a simple TODO app made using Flask. Packages used: DoodleCSS Special thanks to Chris McCormick (@mccrmx) :) Flask Flask-SQLAlchemy Fl

Lenin 1 Dec 26, 2021
Daniel Vaz Gaspar 4k Jan 08, 2023
Web3.py plugin for using Flashbots' bundle APIs

This library works by injecting a new module in the Web3.py instance, which allows submitting "bundles" of transactions directly to miners. This is done by also creating a middleware which captures c

Georgios Konstantopoulos 294 Jan 04, 2023
Light, Flexible and Extensible ASGI API framework

Starlite Starlite is a light, opinionated and flexible ASGI API framework built on top of pydantic and Starlette. Check out the Starlite documentation

Na'aman Hirschfeld 1.6k Jan 09, 2023
Try to create a python mircoservice framework.

Micro current_status: prototype. ... Python microservice framework. More in Document. You should clone this project and run inv docs. Install Not now.

修昊 1 Dec 07, 2021
Cses2humio - CrowdStrike Falcon Event Stream to Humio

CrowdStrike Falcon Event Stream to Humio This project intend to provide a simple

Trifork.Security 6 Aug 02, 2022
Pulumi-checkly - Checkly Pulumi Provider With Python

🚨 This project is still in very early stages and is not stable, use at your own

Checkly 16 Dec 15, 2022
Containers And REST APIs Workshop

Containers & REST APIs Workshop Containers vs Virtual Machines Ferramentas Podman: https://podman.io/ Docker: https://www.docker.com/ IBM CLI: https:/

Vanderlei Munhoz 8 Dec 16, 2021
FPS, fast pluggable server, is a framework designed to compose and run a web-server based on plugins.

FPS, fast pluggable server, is a framework designed to compose and run a web-server based on plugins. It is based on top of fastAPI, uvicorn, typer, and pluggy.

Adrien Delsalle 1 Nov 16, 2021
Fast⚡, simple and light💡weight ASGI micro🔬 web🌏-framework for Python🐍.

NanoASGI Asynchronous Python Web Framework NanoASGI is a fast ⚡ , simple and light 💡 weight ASGI micro 🔬 web 🌏 -framework for Python 🐍 . It is dis

Kavindu Santhusa 8 Jun 16, 2022
An effective, simple, and async security library for the Sanic framework.

Sanic Security An effective, simple, and async security library for the Sanic framework. Table of Contents About the Project Getting Started Prerequis

Sunset Dev 72 Nov 30, 2022
A beginners course for Django

The Definitive Django Learning Platform. Getting started with Django This is the code from the course "Getting Started With Django", found on YouTube

JustDjango 288 Jan 08, 2023
Persistent remote applications for X11; screen sharing for X11, MacOS and MSWindows.

Table of Contents About Installation Usage Help About Xpra is known as "screen for X" : its seamless mode allows you to run X11 programs, usually on a

xpra.org 785 Dec 30, 2022
The comprehensive WSGI web application library.

Werkzeug werkzeug German noun: "tool". Etymology: werk ("work"), zeug ("stuff") Werkzeug is a comprehensive WSGI web application library. It began as

The Pallets Projects 6.2k Jan 01, 2023
Django Ninja - Fast Django REST Framework

Django Ninja is a web framework for building APIs with Django and Python 3.6+ type hints.

Vitaliy Kucheryaviy 3.8k Jan 02, 2023
Distribution Analyser is a Web App that allows you to interactively explore continuous distributions from SciPy and fit distribution(s) to your data.

Distribution Analyser Distribution Analyser is a Web App that allows you to interactively explore continuous distributions from SciPy and fit distribu

Robert Dzudzar 46 Nov 08, 2022
An alternative serializer implementation for REST framework written in cython built for speed.

drf-turbo An alternative serializer implementation for REST framework written in cython built for speed. Free software: MIT license Documentation: htt

Mng 74 Dec 30, 2022
A Flask API REST to access words' definition

A Flask API to access words' definitions

Pablo Emídio S.S 9 Jul 22, 2022
A Python package to easily create APIs in Python.

API_Easy An Python Package for easily create APIs in Python pip install easy-api-builder Requiremnets: = python 3.6 Required modules -- Flask Docume

Envyre-Coding 2 Jan 04, 2022