A micro-framework for the OMG, and code written in Python 3.6+.
Project description
omg.py
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! This framework is being developed for other languages, as well. If you'd like to help, let us know!
Intended / Example Usage
$ cat service.py
import omg
from uuid import uuid4
service = omg.Microservice(name='uuid')
@service.register()
def new(prefix: str) -> str:
"""Generates a UUID, with a given prefix."""
return f'{prefix}{uuid4().hex}'
if __name__ == '__main__':
service.serve(ensure=True)
register takes some optional arguments: name and path. You can also call service.add(f=new), instead.
If not available on disk, the required Dockerfile and microservice.yml files will automatically be generated, for your application:
$ cat microservice.yml
actions:
new:
help: Generates a UUID, with a given prefix.
arguments:
prefix:
in: query
required: true
type: string
http:
method: get
path: /new
port: 8080
output:
type: string
lifecycle:
startup:
command:
- python3
- /app/service.py
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: '/new'
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'
This will spawn a Flask application (using the production-ready waitress web server), preconfigured to serve the masses!
Or, use the omg-cli:
$ omg run new -a prefix='user-'
…
Installation
$ pip install omg.py
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file omg.py-0.3.3.tar.gz.
File metadata
- Download URL: omg.py-0.3.3.tar.gz
- Upload date:
- Size: 6.9 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f5d7e6a6d4dded47ca021033353f41ae2cfb49c089f57505eb8fbaa2db6d545
|
|
| MD5 |
10a0cc65a4da70b56c982d812fa221d6
|
|
| BLAKE2b-256 |
f6b3117c13acc0452b676e31ee30a562247290afa289459a0aae356be8b47c13
|
File details
Details for the file omg.py-0.3.3-py2.py3-none-any.whl.
File metadata
- Download URL: omg.py-0.3.3-py2.py3-none-any.whl
- Upload date:
- Size: 8.1 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e424f58af7333b7fa62c2c9e22a922def75dbc54df2a7e04cde28ec8e82b258d
|
|
| MD5 |
e402058f6ed3d92ed03ad72ce4403fd5
|
|
| BLAKE2b-256 |
42933f3a2082a90fd8c9394c9cf99c16d320dda92be733abdcfebe9ece58275f
|