Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Microservices Without Headaches

Project description

simple-pyms: Python Microservices Without The Headaches

Simple PyMS (SPMS) provides base class abstractions for a very simple microservice architecture. Currently SPMS provides a baseline component that sends heartbeats and a monitor component that tracks microservices and their statuses based on these heartbeats.

The WAMP protocol is used to handle message brokering and RPC. So, to use PyMS you will need a WAMP router such as crossbar.io.

What Does It Do?

SPMS makes creating microservices (WAMP Components) and monitoring them easy. There are two components to deal with - Monitor and Microservice. Monitor monitors Service instances.

So, create a single Monitor instance and one or more Microservice instances. Connect them to the router and you have a poor man's microservice architecture.

Configuring Your Wamp Router

To configure your wamp router, you will need to setup roles for your components. Each microservice component will need to have permissions setup properly for the microservice uri: py.ms.*

permissions:
  # Microservice activities
  - uri: py.ms
    match: prefix
    allow:
      call: true
      register: true
      publish: true
      subscribe: true

Creating A Simple Component

from simplepyms.microservice import mk_component
from autobahn.twisted.component import run
component = mk_component('component-name', 'ws://localhost:8080/ws', 'realm')
run(component)

The code above creates a component that has stop, restart and heartbeat notification built in. Add functionality to make your component more meaningful.

from simplepyms.microservice import mk_component
from autobahn.twisted.component import run
component = mk_component('component-name', 'ws://localhost:8080/ws', 'realm')

@component.register('py.ms.add')
def add(a, b):
    return a + b

run(component)

Project details


Release history Release notifications

This version

0.2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for simple-pyms, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size simple_pyms-0.2.0-py3-none-any.whl (5.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size simple-pyms-0.2.0.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page