proxystore.p2p.messages¶
Message types for peer-to-peer communication.
MessageType ¶
Message
dataclass
¶
Base message.
ServerRegistration
dataclass
¶
ServerResponse
dataclass
¶
PeerConnection
dataclass
¶
Bases: Message
Message used in establishing a peer-to-peer connection.
Attributes:
-
source_uuid
(
uuid.UUID
) –UUID of sending peer.
-
source_name
(
str
) –Name of sending peer.
-
peer_uuid
(
uuid.UUID
) –UUID of destination peer.
-
description_type
(
Literal['answer', 'offer']
) –One of
'answer'
or'offer'
indicating the type of message being sent. -
description
(
str
) –Session description protocol message.
-
error
(
str | None
) –Error string if a problem occurs.
uuid_to_str() ¶
Cast any UUIDs to strings.
Scans the input dictionary for any values where the associated key contains 'uuid' and value is a UUID instance and converts it to a string for jsonification.
Returns:
-
dict[str, Any]
–Shallow copy of the input dictionary with values cast from UUID to str if their key also contains UUID.
Source code in proxystore/p2p/messages.py
str_to_uuid() ¶
Cast any possible UUID strings to UUID objects.
The inverse operation of uuid_to_str().
Returns:
-
dict[str, Any]
–Shallow copy of the input dictionary with values cast from str to UUID if the key also contains UUID.
Raises:
-
MessageDecodeError
–If a key contains 'uuid' but the value cannot be cast to a UUID.
Source code in proxystore/p2p/messages.py
decode() ¶
Decode JSON string into correct Message type.
Parameters:
-
message
(
str
) –JSON string to decode.
Returns:
-
Message
–Parsed message.
Raises:
-
MessageDecodeError
–If the message cannot be decoded.
Source code in proxystore/p2p/messages.py
encode() ¶
Encode message as JSON string.
Parameters:
-
message
(
Message
) –Message to JSON encode.
Raises:
-
MessageEncodeError
–If the message cannot be JSON encoded.