Skip to main content

MongoDB plugging for pynenc, a distributed task queue for Python.

Project description

Pynenc MongoDB Plugin

CI codecov PyPI version Python versions

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

  1. Clone the repository
  2. Install dependencies: poetry install --with dev
  3. Start MongoDB: docker-compose -f docker/docker-compose.yml up -d
  4. 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

pynenc_mongo-0.1.4.tar.gz (163.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pynenc_mongo-0.1.4-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

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

Hashes for pynenc_mongo-0.1.4.tar.gz
Algorithm Hash digest
SHA256 17ebeabd6c711fec1217ad41c1103a10a0731c82aeb8f3a24fa20cf07643366d
MD5 aad70bbabc05ce50536f94ab0941020d
BLAKE2b-256 b953170b88df3f5516ebe6f5780dd8d93076ad68240b7a18d5b603a2b4598c2d

See more details on using hashes here.

File details

Details for the file pynenc_mongo-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pynenc_mongo-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 45f0bac1508abf3d187b987723f544d41ede75120324428655b7c3f0ef8c0a85
MD5 b8c1b3cc52be361ec3f31157cd6a7892
BLAKE2b-256 6081cba57c4ae558b68dd276593ab28f4b5c07c7feff57715a5e6ad031f65b9f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page