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
Metadata
Release files for insanic-framework 0.9.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| insanic-framework-0.9.2.tar.gz | 242.2 kB | Without provenance | Details for insanic-framework-0.9.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| insanic_framework-0.9.2-py3-none-any.whl | Python 3 | none | any | Details for insanic_framework-0.9.2-py3-none-any.whl |
Total release size: 295.6 kB
Release files / insanic-framework-0.9.2.tar.gz
| Download URL | insanic-framework-0.9.2.tar.gz |
|---|---|
| Size | 242.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c67a98e0049fd79567a0476cf6f2ffcf007b25983ddfc0c9bfefc7e4711b5e0f
|
|
BLAKE2b-256 checksum How to use checksums |
c23f81aa5816419d84503c3829502ad6a16d62e24275058be9a6a83c17e96afe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / insanic_framework-0.9.2-py3-none-any.whl
| Download URL | insanic_framework-0.9.2-py3-none-any.whl |
|---|---|
| Size | 53.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
192d5246646e4ac0c1541ea569842ce6392472c99897a43f6755a666bfd5fa88
|
|
BLAKE2b-256 checksum How to use checksums |
45e5040f3f35dd7e54d7aa237d8400fba3ca703350482fe747c0845e68f678c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for insanic-framework 0.9.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.