Skip to main content

qx-regions

Multi-region support for Qx services: tenant home-region resolution, write routing with automatic redirect, and cross-region event replication.

Concepts

  • Home region — the Postgres write primary for a given tenant. All writes must reach the home region; reads can come from any local replica.
  • RegionResolver — maps tenant_id → region_name. Use StaticRegionResolver for tests/simple deployments, DbRegionResolver for production.
  • RegionRouter — given a request's tenant and path, returns a redirect URL when the current region is not the tenant's home region.
  • RegionReplicator — background worker that forwards published outbox events to a remote region's NATS cluster (application-level fallback when JetStream mirroring is not configured).

Usage

from qx.regions import (
    RegionConfig,
    RegionRouter,
    StaticRegionResolver,
    RegionReplicator,
    include_region_tables,
)

# Startup
config = RegionConfig()                   # reads QX_REGION__NAME, QX_REGION__URLS
resolver = StaticRegionResolver(          # or DbRegionResolver for production
    {"tenant-abc": "eu-west-1"},
    default=config.name,
)
router = RegionRouter(resolver, config)

# Per-request — redirect writes to the home region
redirect = await router.get_redirect_url(tenant_id, request.path)
if redirect:
    return Response(status=307, headers={"Location": redirect})

# Cross-region replication worker
replicator = RegionReplicator(
    engine, remote_publisher,
    target_region="eu-west-1",
    events_table=events_t,
    checkpoints_table=checkpoints_t,
)
await replicator.run()   # blocks; call replicator.stop() from signal handler

Metadata

Release files for qx-regions 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qx-regions 1.1.0
File Size Uploaded Provenance Actions
qx_regions-1.1.0.tar.gz 7.8 kB Without provenance Details for qx_regions-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qx-regions 1.1.0
File Interpreter ABI Platform Actions
qx_regions-1.1.0-py3-none-any.whl Python 3 none any Details for qx_regions-1.1.0-py3-none-any.whl

Total release size: 16.0 kB

Release files / qx_regions-1.1.0.tar.gz

Download URL qx_regions-1.1.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
94eada473b2b1c54c25ca37437b81d08691bfd3874352332892f13069e389c6c
BLAKE2b-256 checksum
How to use checksums
e2869af765b275a7ca088eac53e5bc47816ec723984f1a66329c0d5e2336ae99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / qx_regions-1.1.0-py3-none-any.whl

Download URL qx_regions-1.1.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3bcb16b1baf51fd86fd4dfb3e2ec1ed5248184a668dde30e7b8a787ba421656a
BLAKE2b-256 checksum
How to use checksums
457f259567292524ea66a3262b0ba9792600d6f32fcd1f537ea86901202bc7d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for qx-regions 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page