Skip to main content

onestep-postgres

PostgreSQL connector plugin for onestep.

Install it with:

pip install onestep-postgres

YAML resources are available after the plugin is installed:

resources:
  pg:
    type: postgres
    dsn: "${POSTGRES_DSN}"

  cursor:
    type: postgres_cursor_store
    connector: pg

  users:
    type: postgres_incremental
    connector: pg
    table: users
    key: id
    cursor: [updated_at, id]
    state: cursor

  processed:
    type: postgres_table_sink
    connector: pg
    table: processed_users
    mode: upsert
    keys: [id]

The plugin supports table queues, incremental polling, table sinks, SQLAlchemy-backed state/cursor stores, and tracked PostgreSQL executions.

from onestep import ExecutionClient
from onestep_postgres import PostgresExecutionBackend, PostgresExecutionSource

backend = PostgresExecutionBackend(
    dsn="postgresql+psycopg://app:secret@db/app",
    auto_create=True,
    reclaim_batch_size=100,
)
step = ExecutionClient(backend, namespace="agent-api")

async with step:
    execution = await step.submit("run_agent", payload, idempotency_key=request_id)

source = PostgresExecutionSource(
    dsn="postgresql+psycopg://app:secret@db/app",
    auto_create=False,
    namespace="agent-api",
    task_names=("run_agent",),
    worker_id="agent-worker-1",
)

PostgresConnector remains available when an application also needs table queues, sinks, state stores, or one shared pool. In that advanced path use PostgresExecutionBackend.from_connector(pg, ...) for the API or PostgresExecutionSource.from_connector(pg, ...) for the worker; the connector remains owned and closed by the caller. For the direct DSN path, ExecutionClient and PostgresExecutionSource manage the backend lifecycle for their process.

Each execution source accepts exactly one task name, which must match the app task bound to that source. Create a separate source for each additional task.

Execution statuses are queued, running, retrying, succeeded, failed, cancel_requested, cancelled, and expired. Inline payload and result values are limited to 1 MiB each; metadata is limited to 64 KiB. Use auto_create=False after deployment migrations. Execution is at-least-once and cancellation is cooperative; make handler side effects idempotent.

Managed runtime completion persists the handler result. Calling the execution delivery's legacy ack() directly records succeeded with result=None because the public Delivery.ack() API has no result argument. Retryable heartbeat failures use bounded exponential backoff while the lease remains valid. Stale recovery is claim-driven rather than handled by an independent reaper: each claim processes at most reclaim_batch_size records per stale state category, so active workers drain a backlog incrementally. Connector errors use an independent copy returned by PostgresConnector.secret_tokens() for redaction.

The plugin does not support PostgreSQL logical replication or CDC.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onestep_postgres-0.4.0.tar.gz (44.6 kB view details)

Uploaded Source

Built Distribution

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

onestep_postgres-0.4.0-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file onestep_postgres-0.4.0.tar.gz.

File metadata

  • Download URL: onestep_postgres-0.4.0.tar.gz
  • Upload date:
  • Size: 44.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for onestep_postgres-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3debc2f892fcb5da00d27dce72e8167914e9c41ccbd5de3e6a03fb97c73ecf76
MD5 8b5985ccd7b5142a899936c3ee75d37a
BLAKE2b-256 473368e2b5b7496ce77924a06b3175a2cedba57fded88c7d07fdf411bbbcd0f1

See more details on using hashes here.

File details

Details for the file onestep_postgres-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for onestep_postgres-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 190fb3018cc79ae187d2f7c9b6146727ec7bff09222dafe3632386e8c3d8452c
MD5 2f601e81b8624be0f1b82d6b4e6c7c93
BLAKE2b-256 07ae7603f1aeb7072b0c31dab274ccc1f0bea7e6578cf8887d6b66251b7b369c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.0

2 files

0.5.0

2 files

0.4.1

2 files

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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