Skip to content

Message Publishers

MessageQueuePublisherMixin #

Bases: ABC

PublisherMixin.

Mixin for a message queue publisher. Allows for accessing common properties and methods for: - Publisher ID. - Message queue. - Publish callback. - Publish method.

Source code in llama-agents/llama_deploy/message_publishers/publisher.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class MessageQueuePublisherMixin(ABC):
    """PublisherMixin.

    Mixin for a message queue publisher. Allows for accessing common properties and methods for:
    - Publisher ID.
    - Message queue.
    - Publish callback.
    - Publish method.
    """

    @property
    @abstractmethod
    def publisher_id(self) -> str:
        ...

    @property
    @abstractmethod
    def message_queue(self) -> BaseMessageQueue:
        ...

    @property
    def publish_callback(self) -> Optional[PublishCallback]:
        return None

    async def publish(self, message: QueueMessage, **kwargs: Any) -> Any:
        """Publish message."""
        message.publisher_id = self.publisher_id
        return await self.message_queue.publish(
            message, callback=self.publish_callback, **kwargs
        )

publish async #

publish(message: QueueMessage, **kwargs: Any) -> Any

Publish message.

Source code in llama-agents/llama_deploy/message_publishers/publisher.py
31
32
33
34
35
36
async def publish(self, message: QueueMessage, **kwargs: Any) -> Any:
    """Publish message."""
    message.publisher_id = self.publisher_id
    return await self.message_queue.publish(
        message, callback=self.publish_callback, **kwargs
    )

options: members: - MessageQueuePublisherMixin