agency.queue

 1from abc import ABC, ABCMeta, abstractmethod
 2
 3from agency.schema import Message
 4
 5
 6class Queue(ABC, metaclass=ABCMeta):
 7    """
 8    Encapsulates a queue intended to be used for communication
 9    """
10
11    def connect(self) -> None:
12        """
13        Connects to the queue
14
15        This method is called before the queue is first accessed and establishes
16        a connection if necessary.
17        """
18
19    def disconnect(self) -> None:
20        """
21        Disconnects from the queue
22
23        This method is called after the queue will no longer be accessed and
24        closes a connection if necessary.
25        """
26
27    @abstractmethod
28    def put(self, message: Message):
29        """
30        Put a message onto the queue for sending
31
32        Args:
33            message: The message
34        """
35
36    @abstractmethod
37    def get(self, block: bool = True, timeout: float = None) -> Message:
38        """
39        Get the next message from the queue
40
41        Args:
42            block: Whether to block
43            timeout: The timeout
44
45        Returns:
46            The next message
47
48        Raises:
49            queue.Empty: If there are no messages
50        """
class Queue(abc.ABC):
 7class Queue(ABC, metaclass=ABCMeta):
 8    """
 9    Encapsulates a queue intended to be used for communication
10    """
11
12    def connect(self) -> None:
13        """
14        Connects to the queue
15
16        This method is called before the queue is first accessed and establishes
17        a connection if necessary.
18        """
19
20    def disconnect(self) -> None:
21        """
22        Disconnects from the queue
23
24        This method is called after the queue will no longer be accessed and
25        closes a connection if necessary.
26        """
27
28    @abstractmethod
29    def put(self, message: Message):
30        """
31        Put a message onto the queue for sending
32
33        Args:
34            message: The message
35        """
36
37    @abstractmethod
38    def get(self, block: bool = True, timeout: float = None) -> Message:
39        """
40        Get the next message from the queue
41
42        Args:
43            block: Whether to block
44            timeout: The timeout
45
46        Returns:
47            The next message
48
49        Raises:
50            queue.Empty: If there are no messages
51        """

Encapsulates a queue intended to be used for communication

def connect(self) -> None:
12    def connect(self) -> None:
13        """
14        Connects to the queue
15
16        This method is called before the queue is first accessed and establishes
17        a connection if necessary.
18        """

Connects to the queue

This method is called before the queue is first accessed and establishes a connection if necessary.

def disconnect(self) -> None:
20    def disconnect(self) -> None:
21        """
22        Disconnects from the queue
23
24        This method is called after the queue will no longer be accessed and
25        closes a connection if necessary.
26        """

Disconnects from the queue

This method is called after the queue will no longer be accessed and closes a connection if necessary.

@abstractmethod
def put(self, message: agency.schema.Message):
28    @abstractmethod
29    def put(self, message: Message):
30        """
31        Put a message onto the queue for sending
32
33        Args:
34            message: The message
35        """

Put a message onto the queue for sending

Arguments:
  • message: The message
@abstractmethod
def get(self, block: bool = True, timeout: float = None) -> agency.schema.Message:
37    @abstractmethod
38    def get(self, block: bool = True, timeout: float = None) -> Message:
39        """
40        Get the next message from the queue
41
42        Args:
43            block: Whether to block
44            timeout: The timeout
45
46        Returns:
47            The next message
48
49        Raises:
50            queue.Empty: If there are no messages
51        """

Get the next message from the queue

Arguments:
  • block: Whether to block
  • timeout: The timeout
Returns:

The next message

Raises:
  • queue.Empty: If there are no messages