MongoDB plugging for pynenc, a distributed task queue for Python.
Project description
Pynenc MongoDB Plugin
MongoDB state backend plugin for Pynenc, providing distributed task state management using MongoDB as the storage backend.
Features
- 🚀 High Performance: Optimized MongoDB operations with connection pooling
- 🔒 Distributed Locking: MongoDB-based distributed locks for task coordination
- 🎯 Type Safe: Full type hints and mypy compatibility
- 🧪 Well Tested: Comprehensive test suite with multiple MongoDB versions
- 📊 Production Ready: Battle-tested configuration options and monitoring
Quick Start
Installation
pip install pynenc-mongodb
Basic Usage
from pynenc import Pynenc
from pynenc_mongodb import MongoStateBackend
# Create Pynenc app with MongoDB backend
app = Pynenc().with_state_backend(
MongoStateBackend.from_uri("mongodb://localhost:27017/pynenc")
)
@app.task
def my_task(x: int, y: int) -> int:
return x + y
# Use your tasks as normal
result = my_task(1, 2)
Configuration
Connection Configuration
from pynenc_mongodb import MongoStateBackend, ConfigMongoDB
config = ConfigMongoDB(
uri="mongodb://localhost:27017",
database_name="my_pynenc_db",
max_pool_size=100,
write_concern_w="majority",
read_preference="primaryPreferred"
)
backend = MongoStateBackend(config)
Environment Variables
You can also configure via environment variables:
export PYNENC_MONGODB_URI="mongodb://localhost:27017"
export PYNENC_MONGODB_DATABASE="pynenc"
export PYNENC_MONGODB_MAX_POOL_SIZE="100"
Documentation
Development
Setup
- Clone the repository
- Install dependencies:
poetry install --with dev - Start MongoDB:
docker-compose -f docker/docker-compose.yml up -d - Run tests:
poetry run pytest
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pynenc_mongo-0.1.4.tar.gz.
File metadata
- Download URL: pynenc_mongo-0.1.4.tar.gz
- Upload date:
- Size: 163.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17ebeabd6c711fec1217ad41c1103a10a0731c82aeb8f3a24fa20cf07643366d
|
|
| MD5 |
aad70bbabc05ce50536f94ab0941020d
|
|
| BLAKE2b-256 |
b953170b88df3f5516ebe6f5780dd8d93076ad68240b7a18d5b603a2b4598c2d
|
File details
Details for the file pynenc_mongo-0.1.4-py3-none-any.whl.
File metadata
- Download URL: pynenc_mongo-0.1.4-py3-none-any.whl
- Upload date:
- Size: 27.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45f0bac1508abf3d187b987723f544d41ede75120324428655b7c3f0ef8c0a85
|
|
| MD5 |
b8c1b3cc52be361ec3f31157cd6a7892
|
|
| BLAKE2b-256 |
6081cba57c4ae558b68dd276593ab28f4b5c07c7feff57715a5e6ad031f65b9f
|