Skip to main content

light microservice solution

Project description

limis build status limis coverage status

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

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

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

limis-0.0.tar.gz (24.4 kB view details)

Uploaded Source

File details

Details for the file limis-0.0.tar.gz.

File metadata

  • Download URL: limis-0.0.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for limis-0.0.tar.gz
Algorithm Hash digest
SHA256 447d77f04fe295e8cfcbc9b826056b595ea7db80def210d7939d23b34855fb67
MD5 e77660d54eeeb318e7d8aed6e5fe1b44
BLAKE2b-256 ab5adebb1b4d0c8800dd5afce3514293a6dbe54629d229658065f020c850bc3f

See more details on using hashes here.

Supported by

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