Skip to content

API Reference parrot.services.connection_push

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.services.connection_push

View source

Per-principal Redis fan-out of connection events (FEAT-777 M1).

Attribute CHANNEL_TEMPLATE

Alias ConnectionEvent

Re-exported from parrot.auth.oauth2.events.ConnectionEvent.

Class RedisConnectionPush

ConnectionEventSink that publishes every event on the principal's Redis channel.

Any gunicorn worker may publish; any worker may serve the subscriber (subscribe).

Parameter Type Default Description
redis_url str

Method RedisConnectionPush.start

Create the Redis client (aiohttp on_startup).

start() -> None

Method RedisConnectionPush.close

Close the Redis client (aiohttp on_cleanup); safe to call twice.

close() -> None

Method RedisConnectionPush.deliver

PUBLISH event.model_dump_json() on CHANNEL_TEMPLATE.format(user_id=event.user_id).

deliver(event: ConnectionEvent) -> None

Parameter Type Default Description
event ConnectionEvent

Method RedisConnectionPush.subscribe

Yield the principal's events; own pubsub per call; unsubscribes and closes on exit/cancellation.

subscribe(user_id: str, *, ready: Optional[asyncio.Event] = None) -> AsyncIterator[ConnectionEvent]

Parameter Type Default Description
user_id str Principal whose channel is subscribed.
ready Optional[asyncio.Event] None Set once Redis acknowledged the SUBSCRIBE, so a caller can wait for it before announcing the stream (events published earlier are never delivered).

Returns: AsyncIterator[ConnectionEvent]

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally