File size: 1,635 Bytes
079c32c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from typing import Tuple


class MQ:
    """
    Overview:
        Abstract basic mq class.
    """

    def __init__(self, *args, **kwargs) -> None:
        """
        Overview:
            The __init__ method of the inheritance must support the extra kwargs parameter.
        """
        pass

    def listen(self) -> None:
        """
        Overview:
            Bind to local socket or connect to third party components.
        """
        raise NotImplementedError

    def publish(self, topic: str, data: bytes) -> None:
        """
        Overview:
            Send data to mq.
        Arguments:
            - topic (:obj:`str`): Topic.
            - data (:obj:`bytes`): Payload data.
        """
        raise NotImplementedError

    def subscribe(self, topic: str) -> None:
        """
        Overview:
            Subscribe to the topic.
        Arguments:
            - topic (:obj:`str`): Topic
        """
        raise NotImplementedError

    def unsubscribe(self, topic: str) -> None:
        """
        Overview:
            Unsubscribe from the topic.
        Arguments:
            - topic (:obj:`str`): Topic
        """
        raise NotImplementedError

    def recv(self) -> Tuple[str, bytes]:
        """
        Overview:
            Wait for incoming message, this function will block the current thread.
        Returns:
            - data (:obj:`Any`): The sent payload.
        """
        raise NotImplementedError

    def stop(self) -> None:
        """
        Overview:
            Unsubscribe from all topics and stop the connection to the message queue server.
        """
        return