Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
38 changes: 19 additions & 19 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
fail-fast: true
# TODO: Uncomment when we have a tests with database
# services:
# postgres:
# image: postgres:16
# env:
# POSTGRES_USER: taskiq_pg
# POSTGRES_PASSWORD: taskiq_pg
# POSTGRES_DB: taskiq_pg
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
# ports:
# - 5432:5432
services:
postgres:
image: postgres:18
env:
POSTGRES_USER: taskiq_postgres
POSTGRES_PASSWORD: look_in_vault
POSTGRES_DB: taskiq_postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- id: setup-uv
uses: astral-sh/setup-uv@v6
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-suffix: ${{ matrix.python-version }}
version: "latest"
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
if: steps.setup-uv.outputs.cache-hit != 'true'
run: uv sync --all-extras
- name: Run tests
run: uv run pytest
45 changes: 45 additions & 0 deletions .github/workflows/release_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release docs
on:
workflow_dispatch:
inputs:
pr:
description: Pull request number to release docs for
required: true
type: string

pull_request:
types: [closed]
branches: [ main ]

permissions:
contents: write

jobs:
deploy:
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) }}
runs-on: ubuntu-latest
steps:
- name: Checkout merge commit (auto on merge to main)
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}

- name: Checkout PR merge ref (manual on PR)
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: actions/checkout@v5
with:
ref: refs/pull/${{ inputs.pr }}/merge

- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com

- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: "3.12"
version: "latest"
- run: uv sync --only-dev
- run: uv run mkdocs gh-deploy --force
8 changes: 6 additions & 2 deletions .github/workflows/release_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ jobs:
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: "3.12"
version: "latest"
- run: uv version "${{ github.ref_name }}"
- run: uv build
- run: uv publish --trusted-publishing always
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.0
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include src/taskiq_pg/py.typed
58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
args := $(wordlist 2, 100, $(MAKECMDGOALS))

.DEFAULT:
@echo "No such command (or you pass two or many targets to ). List of possible commands: make help"

.DEFAULT_GOAL := help

##@ Local development

.PHONY: help
help: ## Show this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target> <arg=value>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m %s\033[0m\n\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

.PHONY: venv
venv: ## Create a new virtual environment
@uv venv

.PHONY: check_venv
check_venv: ## Check that virtual environment is activated
@if [ -z $$VIRTUAL_ENV ]; then \
echo "Error: Virtual environment is not activated"; \
exit 1; \
fi

.PHONY: init
init: ## Install all project dependencies with extras
@$(MAKE) check_venv
@uv sync --all-extras

.PHONY: run_infra
run_infra: ## Run rabbitmq in docker for integration tests
@docker compose -f docker-compose.yml up -d

##@ Code quality

.PHONY: lint
lint: ## Run linting
@uv run ruff check src tests
@uv run mypy src

.PHONY: format
format: ## Run formatting
@uv run ruff check . --fix

##@ Testing

.PHONY: test
test: ## Run all pytest tests
@uv run pytest tests

.PHONY: test_cov
test_cov: ## Generate test coverage report
@pytest --cov='src' --cov-report=html


.PHONY: test_install
test_install: ## Verify package installation by importing it
@uv run --with taskiq-postgres --no-project -- python -c "import taskiq_pg"
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,34 @@

PostgreSQL integration for Taskiq with support for asyncpg, psqlpy and aiopg drivers.

See more example of usage in [the documentation](https://danfimov.github.io/taskiq-postgres/).

## Installation

Depend on your preferred PostgreSQL driver, you can install this library:

```bash
# with asyncpg
pip install taskiq-postgres[asyncpg]
=== "asyncpg"

# with psqlpy
pip install taskiq-postgres[psqlpy]
```bash
pip install taskiq-postgres[asyncpg]
```

=== "psqlpy"

```bash
pip install taskiq-postgres[psqlpy]
```

=== "aiopg"

```bash
pip install taskiq-postgres[aiopg]
```

# with aiopg
pip install taskiq-postgres[aiopg]
```

## Usage
## Usage example

Simple example of usage with asyncpg:
Simple example of usage with [asyncpg](https://github.com/MagicStack/asyncpg):

```python
# broker.py
Expand Down Expand Up @@ -65,5 +75,5 @@ Your experience with other drivers will be pretty similar. Just change the impor

## Motivation

There are too many libraries for PostgreSQL and Taskiq integration. Although they have different view on interface and different functionality.
To address this issue I created this library with a common interface for most popular PostgreSQL drivers that handle similarity across functionality of result backends and brokers.
There are too many libraries for PostgreSQL and Taskiq integration. Although they have different view on interface and different functionality.
To address this issue I created this library with a common interface for most popular PostgreSQL drivers that handle similarity across functionality of result backends, brokers and schedule sources.
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
postgres:
container_name: taskiq_postgres
image: postgres:18
environment:
POSTGRES_DB: taskiq_postgres
POSTGRES_USER: taskiq_postgres
POSTGRES_PASSWORD: look_in_vault
ports:
- "5432:5432"
11 changes: 11 additions & 0 deletions docs/assets/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added docs/contributing.md
Empty file.
5 changes: 5 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Overview
---

--8<-- "README.md"
9 changes: 9 additions & 0 deletions docs/reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: API
# hide:
# - navigation
---

# ::: taskiq_pg
options:
show_submodules: true
Loading