|
30 | 30 |
|
31 | 31 | class Message: |
32 | 32 | """ |
33 | | - Abstract Message class |
| 33 | + Abstract actor Message class. |
34 | 34 | """ |
35 | 35 |
|
36 | | - def __init__(self, sender_name: str): |
37 | | - self.sender_name = sender_name |
38 | | - |
39 | | - def __str__(self): |
40 | | - raise NotImplementedError() |
41 | | - |
42 | 36 |
|
43 | 37 | class OKMessage(Message): |
44 | 38 | """ |
45 | | - Message sends to acknowledge last received message |
| 39 | + Message sent by an actor after a successful startup. |
46 | 40 | """ |
47 | 41 |
|
48 | | - def __init__(self, sender_name: str): |
49 | | - Message.__init__(self, sender_name) |
50 | | - |
51 | | - def __str__(self): |
52 | | - return "OKMessage" |
53 | | - |
54 | 42 |
|
55 | 43 | class ErrorMessage(Message): |
56 | 44 | """ |
57 | | - Message used to indicate that an error as occuried |
| 45 | + Message sent by an actor when an error occurs during startup. |
58 | 46 | """ |
59 | 47 |
|
60 | | - def __init__(self, sender_name: str, error_message: str): |
| 48 | + def __init__(self, error_message: str): |
61 | 49 | """ |
62 | | - :param str error_code: message associated to the error |
| 50 | + :param error_message: Message associated to the encountered error. |
63 | 51 | """ |
64 | | - Message.__init__(self, sender_name) |
65 | 52 | self.error_message = error_message |
66 | 53 |
|
67 | | - def __str__(self): |
68 | | - return "ErrorMessage : " + self.error_message |
69 | | - |
70 | 54 |
|
71 | 55 | class StartMessage(Message): |
72 | 56 | """ |
73 | | - Message that asks the actor to launch its initialisation process |
| 57 | + Message sent to an actor to initiate its startup. |
74 | 58 | """ |
75 | 59 |
|
76 | | - def __init__(self, sender_name: str): |
77 | | - Message.__init__(self, sender_name) |
78 | | - |
79 | | - def __str__(self): |
80 | | - return "StartMessage" |
81 | | - |
82 | | - |
83 | | -class EndMessage(Message): |
84 | | - """ |
85 | | - Message sent by actor to its parent when it terminates itself |
86 | | - """ |
87 | | - |
88 | | - def __init__(self, sender_name: str): |
89 | | - Message.__init__(self, sender_name) |
90 | | - |
91 | | - def __str__(self): |
92 | | - return "EndMessage" |
93 | | - |
94 | 60 |
|
95 | 61 | class PoisonPillMessage(Message): |
96 | 62 | """ |
97 | | - Message which allow to kill an actor |
| 63 | + Message sent to an actor to initiate its shutdown. |
98 | 64 | """ |
99 | 65 |
|
100 | | - def __init__(self, soft: bool = True, sender_name: str = ''): |
101 | | - Message.__init__(self, sender_name=sender_name) |
| 66 | + def __init__(self, soft: bool = True): |
| 67 | + """ |
| 68 | + :param bool soft: Indicate whether the actor should process all its messages before shutting down. |
| 69 | + """ |
102 | 70 | self.is_soft = soft |
103 | | - self.is_hard = not soft |
104 | | - |
105 | | - def __str__(self): |
106 | | - return "PoisonPillMessage" |
107 | | - |
108 | | - def __eq__(self, other): |
109 | | - if isinstance(other, PoisonPillMessage): |
110 | | - return other.is_soft == self.is_soft and other.is_hard == self.is_hard |
111 | | - return False |
0 commit comments