Skip to main content

A micro-framework for the OMG, and code written in Python 3.6+.

Project description

OMG: Micro Framework

A micro-framework for the excellent Open Microservices Guide, for suppportive code written in Python 3.6+.

Note: this is pre-release software, and is subject to improvement. Contributions are welcome!

Intended / Example Usage

$ cat service.py
import micro
from uuid import uuid4

service = micro.Service(name='uuid')

@service.register('/uuid4', method='get')
def gen_uuid4(prefix: str) -> str:
    """Generates a UUID, with a given prefix."""
    return f'{prefix}{uuid4().hex}'

# Alternative Syntax:
# service.add(f=gen_uuid4)

if __name__ == '__main__':
    service.serve()

If not available on disk, the required Dockerfile and microservice.yml files will automatically be generated, for your application:

$ cat microservice.yml
actions:
  uuid4:
    help: Generates a UUID, with a given prefix.
    http:
      method: get
      path: /uuid4
      port: 8080
    output:
      type: string
omg: 1
$ cat Dockerfile
FROM kennethreitz/pipenv
COPY . /app
CMD ["python3", "service.py"]

Now, run your microservice!

$ python service.py
2019-05-09 14:45:39,342 - micro - DEBUG - Initiating 'uuid' service.
2019-05-09 14:45:39,344 - micro - DEBUG - Registering Flask endpoint: '/uuid4'
2019-05-09 14:45:39,344 - micro - DEBUG - Dockerfile './Dockerfile' already exists!
2019-05-09 14:45:39,345 - micro - DEBUG - Microservice Manifest './microservice.yml' already exists!
2019-05-09 14:45:39,346 - micro - INFO - Serving on: '*:8080'

Or, use the omg-cli:

$ omg run uuid4 -a prefix='user-'

Installation

$ pip install omg-micro

P.S. Do provide feedback, if you desire! :)

✨ 🍰 ✨

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

omg-micro-0.2.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

omg_micro-0.2.0-py2.py3-none-any.whl (4.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file omg-micro-0.2.0.tar.gz.

File metadata

  • Download URL: omg-micro-0.2.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for omg-micro-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e25b6284e59c97d1ff4f737dd5c5de5e43582c3d971a38f044f6873226ec6a42
MD5 c466f41bb50dc698d51d527d5e671534
BLAKE2b-256 366f4d9482199678c10bcbeaed7d4888c1bfd3a996862af3f53d1bff02ce0202

See more details on using hashes here.

File details

Details for the file omg_micro-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: omg_micro-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for omg_micro-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1a14cd2929fab69390d5f7ba314a4ab1108d2c15e29cdfa651e638697fcd1676
MD5 c0e9e200639280862b3960a36cd7d550
BLAKE2b-256 ed966800cc6e826054768a0bab1518d59ab3ddd3c54d6dc1716986d8b1d19b05

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