Giter VIP home page Giter VIP logo

limis's Introduction

limis

limis build status limis coverage status

limis is a light microservice framework built in Python and powered by Tornado.

Warning

The project is currently in active development and should be considered alpha grade at the moment. Features are being added and removed and expect the API to change frequently. Release 0.1 is targeted to be a more stable release.

Examples: limis examples can be found on github at limis_examples

Instructions

Installation

pip install limis

Project Creation

limis-management create_project <project_name>

Service Creation

  • Scaffold the services with the project management command:
cd <project_name>
python management.py create_service <service_name>
  • Create a request handler to route service requests to your component in '<service_name>/handlers.py':
from typing import Union

from tornado.websocket import WebSocketHandler
from limis.services.handlers import ComponentHandler


class HelloHTTPHandler(ComponentHandler):
    def get(self):
        self.write(self.component_class().hello())


class HelloWebSocketHandler(ComponentHandler, WebSocketHandler):
    def on_message(self, message: Union[str, bytes]):
        self.write_message(self.component_class().hello())
  • Create a component to perform actions on requests in '<service_name>/components.py':
from limis.services.components import Component

from hello.handlers import HelloHTTPHandler, HelloWebSocketHandler


class HelloComponent(Component):
    component_name = 'hello'
    component_path = 'hello'
    component_http_handler = HelloHTTPHandler
    component_websocket_handler = HelloWebSocketHandler

    def hello(self):
        return 'hello'
  • Create a services configuration entry in '<service_name>'/services.py:
from limis.services import Service

from hello.components import HelloComponent


services = [
    Service(name='hello', path='hello', components=[HelloComponent]),
]
  • Add your services module to the project services configuration '<project_name>/services.py':
from hello.services import services as hello_services


context_root = ''
services = hello_services

Launch Server

Launch the limis server from the command prompt:

python manage.py server --http --websocket

Test Service

  • HTTP Service
curl http://localhost:8080/hello/hello

Output:

hello
  • WebSocket Service

Example using websocket-client

from websocket import create_connection
websocket = create_connection('ws://localhost:8888/hello/hello/')
websocket.send('test')
websocket.recv()

Output:

hello

limis's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.