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
Release history Release notifications | RSS feed
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.1.tar.gz
(6.1 kB
view hashes)
Built Distribution
Close
Hashes for omg_micro-0.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a30c43ba7c4bfd8b5c80640227a7ac03951935c0dcf43e2afb48379a442c5db6 |
|
MD5 | daaf31ea5618c14fe31377d61337748e |
|
BLAKE2b-256 | 06d19b0aeb362287f97bd18fdf21c159d51f5d957ab6b8826dca166f82110862 |