An API framework that extends sanic with a focus on microservices.
Project description
Insanic
Insanic is a microservice framework that extends sanic. It tries to include all the best practices for developing in a microservice architecture. To do this, certain stacks were needed, as a result Insanic is a pretty opinionated framework.
Think of this as django-rest-framework is to django but for microservice usage (and a lot less functionality than drf).
Why we needed this
We needed this because we need a framework for our developers to quickly develop services while migrating to a microservice architecture.
As stated before, this is very opinionated and the reason being, to reduce research time when trying to select packages to use for their service. It lays down all the necessary patterns and bootstraps the application for quick cycle time between idea and deployment.
FEATURES
Authentication and Authorization for Users and other Services (like drf)
Easy Service Requests
Normalized Error Message Formats
Connection manager to redis
Utils for extracting public routes (will help when registering to api gateway)
Bootstrap monitoring endpoints
Throttling
Documentation
For more detailed information please refer to the documentation
Installation
Prerequisites
Core dependencies include:
sanic - extends sanic
httpx - to make async requests to other services
PyJWT - for authentication
Redis - for cache and throttling
To install:
$ pip install insanic-framework
Usage
For very basic usage, it is pretty much the same as Sanic:
Create a python file. ex. app.py
from insanic import Insanic
from insanic.conf import settings
from sanic.response import json
settings.configure()
__version__ = "0.1.0"
app = Insanic(__name__, version=__version__)
@app.route('/')
async def example(request):
return json({"insanic": "Gotta go insanely fast!"})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000)
Run with
python run.py
Check in browser or curl
curl http://localhost:8000/
For more examples and usage, please refer to the documentation.
Testing
Insanic tests are run with pytest and tox.
$ pytest
# with coverage
$ pytest --cov=insanic --cov-report term-missing:skip-covered
# a certain set of tests
$ pytest --pytest-args tests/test_pact.py
# tox, run for sanic > 19.12 and python >= 3.6
$ tox
Release History
For full changelogs, please refer to the CHANGELOG.rst.
Since Insanic was initially developed and released internally, for changes made during that period, please refer to CHANGELOG_LEGACY.rst.
Contributing
For guidance on setting up a development environment and how to make a contribution to Insanic, see the CONTRIBUTING.rst guidelines.
Known Issues
Insanic cannot run with more than 1 worker.
Meta
Distributed under the MIT license. See LICENSE for more information.
Thanks to all the people at my prior company that worked with me to make this possible.
Links
Documentation: http://insanic.readthedocs.io/
Issue Tracker: https://www.github.com/crazytruth/insanic/issues
Sanic Documentation: https://sanic.readthedocs.io/en/latest/index.html
Sanic Repository: https://github.com/huge-success/sanic
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
File details
Details for the file insanic-framework-0.9.2.tar.gz
.
File metadata
- Download URL: insanic-framework-0.9.2.tar.gz
- Upload date:
- Size: 242.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c67a98e0049fd79567a0476cf6f2ffcf007b25983ddfc0c9bfefc7e4711b5e0f |
|
MD5 | 79564906ca042de2a3dcbafaf17d9b21 |
|
BLAKE2b-256 | c23f81aa5816419d84503c3829502ad6a16d62e24275058be9a6a83c17e96afe |
File details
Details for the file insanic_framework-0.9.2-py3-none-any.whl
.
File metadata
- Download URL: insanic_framework-0.9.2-py3-none-any.whl
- Upload date:
- Size: 53.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 192d5246646e4ac0c1541ea569842ce6392472c99897a43f6755a666bfd5fa88 |
|
MD5 | 716351e812e859e714d86718c557d8a0 |
|
BLAKE2b-256 | 45e5040f3f35dd7e54d7aa237d8400fba3ca703350482fe747c0845e68f678c8 |