Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Message class #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions distalg/message.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
class Message:
def __init__(self, from_channel=None, **kwargs):
"""
A message object is the one that is used to carry information across processes.

:param from_channel (Channel, optional): The channel on which this will be sent on.
Because at the receiving end we can find out which channel it came from after receiving it.
:param kwargs : all the keywords are set as attributes of the resulting object with the argument
as their values
"""
self._channel = from_channel
if kwargs is not None:
for key, value in kwargs.items():
setattr(self, key, value)

@property
def carrier(self):
"""
At the receiving end it returns the channel is came through

:return: (Channel) The channel it came through
"""
return self._channel

if __name__ == "__main__":
Expand Down