proxystore.p2p.relay.messages¶
Message types for relay client and relay server communication.
RelayMessageType ¶
RelayMessage
dataclass
¶
Base message.
RelayRegistrationRequest
dataclass
¶
Bases: RelayMessage
Register with relay server as peer.
Attributes:
-
name
(str
) –Name of peer requesting to register.
-
uuid
(UUID
) –UUID of peer requesting to register.
RelayResponse
dataclass
¶
Bases: RelayMessage
Message returned by relay server on success or error.
Attributes:
-
success
(bool
) –If the registration was successful.
-
message
(str | None
) –Message from server.
-
error
(bool
) –If
message
is an error message.
PeerConnectionRequest
dataclass
¶
Bases: RelayMessage
Message used to request a peer-to-peer connection from a relay.
Attributes:
-
source_uuid
(UUID
) –UUID of sending peer.
-
source_name
(str
) –Name of sending peer.
-
peer_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.
RelayMessageDecodeError ¶
Bases: RelayMessageError
Exception raised when a message cannot be decoded.
RelayMessageEncodeError ¶
Bases: RelayMessageError
Exception raised when an message cannot be encoded.
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/relay/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:
-
RelayMessageDecodeError
–If a key contains 'uuid' but the value cannot be cast to a UUID.
Source code in proxystore/p2p/relay/messages.py
decode_relay_message() ¶
Decode JSON string into correct relay message type.
Parameters:
-
message
(str
) –JSON string to decode.
Returns:
-
RelayMessage
–Parsed message.
Raises:
-
RelayMessageDecodeError
–If the message cannot be decoded.
Source code in proxystore/p2p/relay/messages.py
encode_relay_message() ¶
Encode message as JSON string.
Parameters:
-
message
(RelayMessage
) –Message to JSON encode.
Raises:
-
RelayMessageEncodeError
–If the message cannot be JSON encoded.