Skip to content

Commit 55660b8

Browse files
authored
feat: same interface for all brokers/result backends (#10)
2 parents 7184f3a + 385d56b commit 55660b8

28 files changed

+1496
-579
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "uv"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "monthly"

.github/workflows/code-check.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,32 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
14+
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
1515
fail-fast: true
16-
# TODO: Uncomment when we have a tests with database
17-
# services:
18-
# postgres:
19-
# image: postgres:16
20-
# env:
21-
# POSTGRES_USER: taskiq_pg
22-
# POSTGRES_PASSWORD: taskiq_pg
23-
# POSTGRES_DB: taskiq_pg
24-
# options: >-
25-
# --health-cmd pg_isready
26-
# --health-interval 10s
27-
# --health-timeout 5s
28-
# --health-retries 5
29-
# ports:
30-
# - 5432:5432
16+
services:
17+
postgres:
18+
image: postgres:18
19+
env:
20+
POSTGRES_USER: taskiq_postgres
21+
POSTGRES_PASSWORD: look_in_vault
22+
POSTGRES_DB: taskiq_postgres
23+
options: >-
24+
--health-cmd pg_isready
25+
--health-interval 10s
26+
--health-timeout 5s
27+
--health-retries 5
28+
ports:
29+
- 5432:5432
3130
steps:
32-
- uses: actions/checkout@v4
31+
- uses: actions/checkout@v5
3332
- id: setup-uv
34-
uses: astral-sh/setup-uv@v6
33+
uses: astral-sh/setup-uv@v7
3534
with:
3635
enable-cache: true
36+
cache-suffix: ${{ matrix.python-version }}
37+
version: "latest"
3738
python-version: ${{ matrix.python-version }}
3839
- name: Install Dependencies
39-
if: steps.setup-uv.outputs.cache-hit != 'true'
4040
run: uv sync --all-extras
4141
- name: Run tests
4242
run: uv run pytest

.github/workflows/release_docs.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release docs
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
pr:
6+
description: Pull request number to release docs for
7+
required: true
8+
type: string
9+
10+
pull_request:
11+
types: [closed]
12+
branches: [ main ]
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
deploy:
19+
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) }}
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout merge commit (auto on merge to main)
23+
if: ${{ github.event_name == 'pull_request' }}
24+
uses: actions/checkout@v5
25+
with:
26+
ref: ${{ github.event.pull_request.merge_commit_sha }}
27+
28+
- name: Checkout PR merge ref (manual on PR)
29+
if: ${{ github.event_name == 'workflow_dispatch' }}
30+
uses: actions/checkout@v5
31+
with:
32+
ref: refs/pull/${{ inputs.pr }}/merge
33+
34+
- name: Configure Git Credentials
35+
run: |
36+
git config user.name github-actions[bot]
37+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
38+
39+
- uses: astral-sh/setup-uv@v7
40+
with:
41+
enable-cache: true
42+
python-version: "3.12"
43+
version: "latest"
44+
- run: uv sync --only-dev
45+
- run: uv run mkdocs gh-deploy --force

.github/workflows/release_pypi.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ jobs:
1515
permissions:
1616
id-token: write
1717
steps:
18-
- uses: actions/checkout@v4
19-
- uses: astral-sh/setup-uv@v6
18+
- uses: actions/checkout@v5
19+
- uses: astral-sh/setup-uv@v7
20+
with:
21+
enable-cache: true
22+
python-version: "3.12"
23+
version: "latest"
2024
- run: uv version "${{ github.ref_name }}"
2125
- run: uv build
2226
- run: uv publish --trusted-publishing always

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.14.0
4+
hooks:
5+
- id: ruff-check
6+
args: [--fix]
7+
- id: ruff-format

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include src/taskiq_pg/py.typed

Makefile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
args := $(wordlist 2, 100, $(MAKECMDGOALS))
2+
3+
.DEFAULT:
4+
@echo "No such command (or you pass two or many targets to ). List of possible commands: make help"
5+
6+
.DEFAULT_GOAL := help
7+
8+
##@ Local development
9+
10+
.PHONY: help
11+
help: ## Show this help
12+
@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)
13+
14+
.PHONY: venv
15+
venv: ## Create a new virtual environment
16+
@uv venv
17+
18+
.PHONY: check_venv
19+
check_venv: ## Check that virtual environment is activated
20+
@if [ -z $$VIRTUAL_ENV ]; then \
21+
echo "Error: Virtual environment is not activated"; \
22+
exit 1; \
23+
fi
24+
25+
.PHONY: init
26+
init: ## Install all project dependencies with extras
27+
@$(MAKE) check_venv
28+
@uv sync --all-extras
29+
30+
.PHONY: run_infra
31+
run_infra: ## Run rabbitmq in docker for integration tests
32+
@docker compose -f docker-compose.yml up -d
33+
34+
##@ Code quality
35+
36+
.PHONY: lint
37+
lint: ## Run linting
38+
@uv run ruff check src tests
39+
@uv run mypy src
40+
41+
.PHONY: format
42+
format: ## Run formatting
43+
@uv run ruff check . --fix
44+
45+
##@ Testing
46+
47+
.PHONY: test
48+
test: ## Run all pytest tests
49+
@uv run pytest tests
50+
51+
.PHONY: test_cov
52+
test_cov: ## Generate test coverage report
53+
@pytest --cov='src' --cov-report=html
54+
55+
56+
.PHONY: test_install
57+
test_install: ## Verify package installation by importing it
58+
@uv run --with taskiq-postgres --no-project -- python -c "import taskiq_pg"

README.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,34 @@
99

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

12+
See more example of usage in [the documentation](https://danfimov.github.io/taskiq-postgres/).
13+
1214
## Installation
1315

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

16-
```bash
17-
# with asyncpg
18-
pip install taskiq-postgres[asyncpg]
18+
=== "asyncpg"
1919

20-
# with psqlpy
21-
pip install taskiq-postgres[psqlpy]
20+
```bash
21+
pip install taskiq-postgres[asyncpg]
22+
```
23+
24+
=== "psqlpy"
25+
26+
```bash
27+
pip install taskiq-postgres[psqlpy]
28+
```
29+
30+
=== "aiopg"
31+
32+
```bash
33+
pip install taskiq-postgres[aiopg]
34+
```
2235

23-
# with aiopg
24-
pip install taskiq-postgres[aiopg]
25-
```
2636

27-
## Usage
37+
## Usage example
2838

29-
Simple example of usage with asyncpg:
39+
Simple example of usage with [asyncpg](https://github.com/MagicStack/asyncpg):
3040

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

6676
## Motivation
6777

68-
There are too many libraries for PostgreSQL and Taskiq integration. Although they have different view on interface and different functionality.
69-
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.
78+
There are too many libraries for PostgreSQL and Taskiq integration. Although they have different view on interface and different functionality.
79+
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.

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
postgres:
3+
container_name: taskiq_postgres
4+
image: postgres:18
5+
environment:
6+
POSTGRES_DB: taskiq_postgres
7+
POSTGRES_USER: taskiq_postgres
8+
POSTGRES_PASSWORD: look_in_vault
9+
ports:
10+
- "5432:5432"

docs/assets/favicon.svg

Lines changed: 11 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)