djmicroservice
django restfull框架下的微服务应用包。
一. 安装
-
依赖包
- django >=2.0
- djangorestframework >=3.8
- djangorestframework-jwt >=1.6
- djkeeper >=0.2
- South >=1.0
- coreapi >=2.3.3
- simple-rest-client >=0.5.2
- stomp.py >=4.1.20
-
安装
#pip install -r requirements.txt #python setup.py install -
配置
-
django 配置
- INSTALLED_APPS配置项增加
INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'djmicroservice', ]- 增加 REST_FRAMEWORK配置项
REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': ( ), 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework_jwt.authentication.JSONWebTokenAuthentication', ), }- 增加 REST_FRAMEWORK配置项
REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': ( ), 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework_jwt.authentication.JSONWebTokenAuthentication', ), }- 增加 JWT_AUTH配置项
JWT_AUTH = { 'JWT_ENCODE_HANDLER':'rest_framework_jwt.utils.jwt_encode_handler', 'JWT_DECODE_HANDLER':'rest_framework_jwt.utils.jwt_decode_handler', 'JWT_PAYLOAD_HANDLER':'user.jwt.handlers.onlyuser_jwt_payload_handler', 'JWT_PAYLOAD_GET_USER_ID_HANDLER':'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler', 'JWT_RESPONSE_PAYLOAD_HANDLER':'user.jwt.handlers.onlyuser_jwt_response_payload_handler', 'JWT_SECRET_KEY': SECRET_KEY, 'JWT_GET_USER_SECRET_KEY': None, 'JWT_PUBLIC_KEY': None, 'JWT_PRIVATE_KEY': None, 'JWT_ALGORITHM': 'HS256', 'JWT_VERIFY': True, 'JWT_VERIFY_EXPIRATION': True, 'JWT_LEEWAY': 0, 'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=36000), 'JWT_AUDIENCE': None, 'JWT_ISSUER': None, 'JWT_ALLOW_REFRESH': True, 'JWT_REFRESH_EXPIRATION_DELTA': datetime.timedelta(days=7), 'JWT_AUTH_HEADER_PREFIX': 'JWT', 'JWT_AUTH_COOKIE': None, }- 增加 DJMICROSERVICE配置项
DJMICROSERVICE = { #微服务名字 'NAME': DEFAULT_NAME , #微服务URL 'URL': 'http://127.0.0.1:8000/', #是否是主节点 'MASTER': True, #微服务资源 'RESOURCES': { }, #服务发现配置 'DISCOVER': { #是否注册 'REGISTER': False, #心跳 'HEARTBEAT': 15, #发现者引擎 'ENGINE': 'djmicroservice.discovers.backends.StaticDiscover', #引擎配置 'OPTIONS': { 'SERVICES':[ ] }, }, #客户端配置 'CLIENT':{ #认证管理微服务名 'AUTH': None, 'OBTAIN': None, 'REFRESH': None, 'VERIFY': None, 'USER': None, 'PASSWORD': None, 'JWT_HEADER_PFX': 'JWT', 'TIMEOUT': 2, 'AUTO_LOGIN': False, }, #消息队列端配置 'MQ':{ #消息队列引擎 'ENGINE': 'djmicroservice.mq.backends.ActiveMQ', #引擎配置 'OPTIONS': { #消息服务器地址,可以多个 'SERVERS': [('127.0.0.1',61613)], #消息服务器登录名 'USER': 'admin', #消息服务器密码 'PASSWORD': 'admin', }, 'HANDLERS': { }, }, 'SERVICE_MANAGER':{ #服务管理地址 'BIND':('127.0.0.1',56560), 'AUTH_KEY':None, #要启动的服务 'SERVICES':[ ('onlyuser.mq.service.MQService', 1), ] } }
-
二. RESTful API规范
Metadata
Release files for djmicroservice 1.0.7
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 |
|---|---|---|---|---|
| djmicroservice-1.0.7.tar.gz | 22.8 kB | Without provenance | Details for djmicroservice-1.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| djmicroservice-1.0.7-py3-none-any.whl | Python 3 | none | any | Details for djmicroservice-1.0.7-py3-none-any.whl |
Total release size: 54.4 kB
Release files / djmicroservice-1.0.7.tar.gz
| Download URL | djmicroservice-1.0.7.tar.gz |
|---|---|
| Size | 22.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8bf6380ba7749554635c4cf9ee49acf2a8408fe947dfc3ec577ea197b71e08eb
|
|
BLAKE2b-256 checksum How to use checksums |
9d474f2420b77cc35b5a70fbb2d75a049aab35e19b441c46ff9c5f94abbf5315
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.9
|
Release files / djmicroservice-1.0.7-py3-none-any.whl
| Download URL | djmicroservice-1.0.7-py3-none-any.whl |
|---|---|
| Size | 31.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c2d24e245cfdbe0733941464b568e37c2c2d2c1af49acdf98e680f3e5fe27c56
|
|
BLAKE2b-256 checksum How to use checksums |
0b2e02a614d5af2296ff543303dd1e2207ca72d091cadc727090f3ff260c9d87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.9
|
Security for djmicroservice 1.0.7
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.