pulsar.client.transport package
Submodules
pulsar.client.transport.curl module
pulsar.client.transport.relay module
HTTP transport for communicating with pulsar-relay.
Provides methods for posting messages, long-polling, and managing authentication with the relay server.
- class pulsar.client.transport.relay.RelayTransport(relay_url: str, username: str, password: str, timeout: int = 30, cursor_path: str | None = None)[source]
Bases:
objectHTTP transport for pulsar-relay communication.
Handles: - Message publishing (single and bulk) - Long-polling for message consumption - Automatic authentication and retry
- clear_tracked_message_ids(topic: str | None = None) None[source]
Clear tracked message IDs.
- Args:
- topic: If provided, clears only the specified topic.
If None, clears all tracked message IDs.
- get_all_tracked_message_ids() Dict[str, str][source]
Get all tracked message IDs.
- Returns:
Dictionary mapping topic names to last message IDs
- get_last_message_id(topic: str) str | None[source]
Get the last tracked message ID for a topic.
- Args:
topic: Topic name
- Returns:
Last message ID for the topic, or None if not tracked
- long_poll(topics: List[str], timeout: int = 30) List[Dict[str, Any]][source]
Poll for messages from specified topics.
This is a blocking call that waits up to ‘timeout’ seconds for new messages. Automatically tracks the last message ID per topic and includes it in subsequent poll requests to ensure no messages are missed.
- Args:
topics: List of topic names to subscribe to timeout: Maximum seconds to wait for messages (1-60)
- Returns:
List of message dictionaries
- Raises:
RelayTransportError: If the request fails
- post_bulk_messages(messages: List[Dict[str, Any]]) Dict[str, Any][source]
Post multiple messages in a single request.
Automatically retries on communication errors and server errors (5xx) with exponential backoff. Does not retry on client errors (4xx).
- Args:
messages: List of message dictionaries, each containing ‘topic’ and ‘payload’
- Returns:
Response dictionary with results and summary
- Raises:
RelayTransportError: If the request fails with a client error (4xx)
- post_message(topic: str, payload: Dict[str, Any], ttl: int | None = None, metadata: Dict[str, str] | None = None) Dict[str, Any][source]
Post a single message to the relay.
Automatically retries on communication errors and server errors (5xx) with exponential backoff. Does not retry on client errors (4xx).
- Args:
topic: Topic name to publish to payload: Message payload (must be JSON-serializable) ttl: Time-to-live in seconds (optional) metadata: Optional metadata dictionary
- Returns:
Response dictionary with message_id, topic, and timestamp
- Raises:
RelayTransportError: If the request fails with a client error (4xx)
pulsar.client.transport.requests module
pulsar.client.transport.ssh module
pulsar.client.transport.standard module
Pulsar HTTP Client layer based on Python Standard Library (urllib)