Skip to main content

vbp-bid-common

vbp-bid-common 是 VBP Bid Copilot 的公共基础包,当前提供异步 Redis 与 MongoDB 客户端封装,便于多个服务复用同一套缓存、队列、分布式锁和基础 CRUD 能力。

安装

pip install vbp-bid-common

本地开发时可在仓库根目录执行:

pip install -e ./vbp-bid-common[dev]

使用示例

from vbp_bid_common import get_mongodb_client, get_redis_client


async def main() -> None:
    redis_client = get_redis_client()
    await redis_client.set("demo:key", "value", ex=60)
    value = await redis_client.get("demo:key")

    mongo_client = get_mongodb_client(default_collection="demo")
    inserted_id = await mongo_client.insert_one({"value": value})
    doc = await mongo_client.find_one({"_id": inserted_id})

也可以按模块导入:

from vbp_bid_common.services.mongodb import MongoDBClient
from vbp_bid_common.services.redis import RedisClient

环境变量

Redis 客户端支持以下环境变量:

  • REDIS_HOST,默认 127.0.0.1
  • REDIS_PORT,默认 6379
  • REDIS_DB,默认 0
  • REDIS_USERNAME
  • REDIS_PASSWORD
  • REDIS_DECODE_RESPONSES,默认 true
  • REDIS_MAX_CONNECTIONS,默认 100
  • REDIS_CONNECTION_POOL_TIMEOUT,默认 10
  • REDIS_SOCKET_TIMEOUT
  • REDIS_SOCKET_CONNECT_TIMEOUT

MongoDB 客户端支持以下环境变量:

  • MONGODB_URI,默认 mongodb://127.0.0.1:27017
  • MONGODB_DATABASE,默认 test-technical
  • MONGODB_COLLECTION_NAME
  • MONGODB_MAX_POOL_SIZE
  • MONGODB_MIN_POOL_SIZE
  • MONGODB_SERVER_SELECTION_TIMEOUT_MS

发布到 PyPI

首次发布前需要注册并配置 PyPI API Token:

python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
python -m twine upload dist/*

发布测试包可先使用 TestPyPI:

python -m twine upload --repository testpypi dist/*

每次发布前请更新 pyproject.toml 中的 version,并确认 README.md、LICENSE 与依赖声明已同步。

开源协议

本项目使用 Apache License 2.0。详见 LICENSE。

Metadata

Release files for vbp-bid-common 0.3.33

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vbp-bid-common 0.3.33
File Size Uploaded
vbp_bid_common-0.3.33.tar.gz 37.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vbp-bid-common 0.3.33
File Interpreter ABI Platform
vbp_bid_common-0.3.33-py3-none-any.whl Python 3 none any Details

Total release size: 84.1 kB

Release files / vbp_bid_common-0.3.33.tar.gz

Download URL vbp_bid_common-0.3.33.tar.gz
Size 37.0 kB
Tags Source
SHA-256 checksum
How to use checksums
23cf9f7a4a7137764952205f7dcb0f354e9a2bf17bc0a3d147d4ffa35a822a46
BLAKE2b-256 checksum
How to use checksums
0f301bdf5f73df6d096c6c7d036965633e6446c32a8e29459f69eef51b9a644e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / vbp_bid_common-0.3.33-py3-none-any.whl

Download URL vbp_bid_common-0.3.33-py3-none-any.whl
Size 47.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf2e57bb904611b094baf85ffc60d5e772abf2de818c54e66d071d8aa3a65697
BLAKE2b-256 checksum
How to use checksums
d45c2691b927b0d5ee899d879a23889c618bd75616ff610804f373856dfe6db6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release history Release notifications | RSS feed

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

This release

0.3.33 This release

2 release files

0.3.30

2 release files

0.3.25

2 release files

0.3.24

2 release files

0.3.21

2 release files

0.3.19

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page