一个简单的Django应用程序,用于启用通配符入口
项目描述
数据入口
这是一个简单的入口应用程序,将所有传入的消息存储在队列中,并按集合分类。
数据始终以消息的形式发布到特定的集合中,可以通过消费者从队列中处理。
用法
1. 添加应用程序
在已安装的应用程序中启用
INSTALLED_APPS = [
...,
'ingress'
]
2. 创建和配置消费者
实现一个消费者来处理数据。注意:如果您(可能暂时)想导入数据但不消费它,可以不部署消费者而部署入口。
class MyConsumer(IngressConsumer):
collection_name = 'foobar'
def consume_message(self):
...
# by default consume_batch() loops and calls consume_message(), but it can be
# overridden to have more control, for instance to bulk insert into the db.
def consume_batch(self):
...
在settings.py中配置消费者。每个消费者都必须实现BaseConsumer并实现适当的方法(见上面)。在消费时,消费者会接收到与Consumer.collection_name
对应的集合中的所有消息。
# A list of classpaths to implementations of ingress.consumer.IngressConsumer
# to handle the data in the queue.
INGRESS_CONSUMER_CLASSES = ['app.module.MyConsumer']
3. 身份验证和授权
至少配置身份验证类或权限类,或完全禁用身份验证
# A list of authentication classes used in the ingress view.
# See https://django-rest-framework.django.ac.cn/api-guide/authentication/
INGRESS_AUTHENTICATION_CLASSES = []
# A list of permission classes used in the ingress view.
# See https://django-rest-framework.django.ac.cn/api-guide/permissions/
INGRESS_PERMISSION_CLASSES = []
# If the queue is used without the endpoint, authentication checks can be
# disabled by setting this flag to True. Defaults to False.
INGRESS_DISABLE_ALL_AUTH_PERMISSION_CHECKS = True
接受发布到非现有集合的数据?
默认情况下,发布到非现有集合的数据不会存储,并且对于此类请求将返回错误。
如果应将发布到非现有集合的数据存储,则修改设置
# Whether or not to accept data posted to a non-existing collection.
INGRESS_ACCEPT_NEW_COLLECTIONS = False
设置其他于UTF-8时的编码
默认情况下,入口使用UTF-8解码所有传入数据。如果需要在存储到数据库之前以不同方式解码数据,则配置设置
# Encoding that the data will be in when posted to the ingress
INGRESS_ENCODING = "utf-16"
项目详情
下载文件
下载适用于您平台文件的文件。如果您不确定选择哪一个,请了解有关安装包的更多信息。
源分布
datapunt-data-ingress-2.3.0.tar.gz (17.9 kB 查看哈希值)
构建分布
关闭
datapunt-data-ingress-2.3.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 3c1977b301f5c38c5a7b9a0620c889cd069d3add9ccec1229d381b8d90007f79 |
|
MD5 | 810c9b49d4a2997623fce8ac19137d6d |
|
BLAKE2b-256 | 1e85791d6c49e74bcc60523c2228faaa6ebc350618e7de9dd8a7c251bbc263c3 |
关闭
datapunt_data_ingress-2.3.0-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 8b3566da8b78bff04a67e47d73e755ca6129cdbeeec8de6626aece754788c7e1 |
|
MD5 | bc13a1f2e1e490a0d20d4ee589a8e9e3 |
|
BLAKE2b-256 | c454b914b27e6d389a8fd711ef92dc8456dcc222fefbb53c901c46f98ae5844e |