具有aether python功能的python库

aether.python的Python项目详细描述


以太Python库

这是带有aether函数的正式python库。

目录

要求

此库需要python 3.6及更高版本。

python库:

  • eha-jsonpath 为jsonpath_ng python库提供新的扩展,以提供通常请求的函数
  • jsonschema python的json模式验证的实现
  • redis 用于redis密钥值存储的python客户端
  • requests 人类的http。
  • spavro 一个avro库,spavro是一个(sp)eedier avro实现,使用cython

额外依赖项(基于设置):

  • 测试
    • coverage 一种测量python程序代码覆盖率的工具。
    • fakeredis 用于测试目的的redis api的伪实现。
    • flake8 执行样式指南的工具。
    • flake8-quotes flake8扩展,用于检查python中的引号。
    • tblib 回溯序列化库。

Return to TOC

安装

# standalone
pip3 install aether.python

Return to TOC

分布

如何创建软件包分发版

执行以下命令:

python3 setup.py bdist_wheel

./scripts/build.sh

Return to TOC

测试

如何测试库

首次安装依赖项(仅执行一次):

./scripts/install.sh

之后执行以下命令:

source ./venv/bin/activate
./scripts/test.sh

文件scripts/test.ini包含测试中使用的环境变量。

Return to TOC

用法

redis工具

它通过提供的redis参数提供到redis服务器的接口。

它提供了许多CRUDredis操作,包括但不限于: -在缓存到redis之前,将文档键格式化为_{type}:{tenant}:{id}。 -基于预成形键检索文档。 -基于预成形键移除文档。 -使用回调函数订阅基于密钥的通道。

用法

from aether.python.redis.task import TaskHelper

REDIS_TASK = TaskHelper(settings, redis_instance)

# Settings must have the following properties:
# REDIS_HOST str - Redis server host,
# REDIS_PORT int - Redis server port,
# REDIS_PASSWORD str - Redis server password,
# REDIS_DB str - Redis database name

# redis_instance (Optional) - Pass an existing redis connection
# (If provided, ignores all settings and uses redis_instance)

document = {
    'id': 'document_id',
    'name': 'document name'
}

document_type = 'test_document'
aether_tenant = 'prod'

# add document to redis
REDIS_TASK.add(task=document, type=document_type, tenant=aether_tenant)

# retrieve document from redis
REDIS_TASK.get(_id=document['id'], type=document_type, tenant=aether_tenant)

# subcribe to a key based channel

CHANNEL = '_test_document*' # listens for messages published to all channels starting with '_test_document'

def handle_callback(msg):
    print(msg) # handle returned message

REDIS_TASK.subscribe(callback=handle_callback, pattern=CHANNEL, keep_alive=True)


# publish document
REDIS_TASK.publish(task=document, type=document_type, tenant=aether_tenant) # this will trigger the 'handle_callback' function with the published document to all subscribed clients

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java变量始终存储0值。为什么?   如何使用Java/REST将Azure blob从一个存储容器移动到另一个存储容器?   java将commons DBCP从1.2升级到1.4,我应该害怕吗?   java如何使用分隔符拆分字符串?   java使用数组读取json对象   java在groovy中切片字符串   交换数组java的两个邻域元素   java移动用于确定字符串是否为回文的逻辑   java Android应用程序在一个活动中崩溃   java Sparkjava将webapp文件夹设置为静态资源/模板的文件夹   java复杂条件表达式,用户易用。   java如何仅在表存在时从表中选择值   java I无法将数据从Recyclerview传递到其他活动   java数据结构最佳设计(大数据)   java Android从DatePickerDialogFragment中删除日历视图   java将数据从Firebase获取到片段   数组。sort()在java中运行不正常