Description
Add __acall__ (or the Django 4.1+ async middleware pattern) to RLSTenantMiddleware so it runs natively in the ASGI event loop without sync_to_async thread-hops. Uses aset_guc() / aclear_guc() for GUC operations.
Tier 3 — depends on Tier 1 (async GUC primitives).
Must remain backward-compatible — sync WSGI deployments must continue working identically.
Why
The current MiddlewareMixin-based middleware works under ASGI but forces a sync-to-async thread-hop per request. For high-concurrency ASGI deployments, this adds latency and limits throughput. A native async path eliminates the thread-pool bottleneck.
Roadmap reference
v1.4.0 — Async Support
Description
Add
__acall__(or the Django 4.1+ async middleware pattern) toRLSTenantMiddlewareso it runs natively in the ASGI event loop withoutsync_to_asyncthread-hops. Usesaset_guc()/aclear_guc()for GUC operations.Tier 3 — depends on Tier 1 (async GUC primitives).
Must remain backward-compatible — sync WSGI deployments must continue working identically.
Why
The current
MiddlewareMixin-based middleware works under ASGI but forces a sync-to-async thread-hop per request. For high-concurrency ASGI deployments, this adds latency and limits throughput. A native async path eliminates the thread-pool bottleneck.Roadmap reference
v1.4.0 — Async Support