proxystore.endpoint.peers¶
Peer endpoint allowlist.
An endpoint only communicates with the peer endpoints in its allowlist,
the peers.toml file in the endpoint directory. Allowlisting is
symmetric: two endpoints can only communicate if each endpoint lists the
other.
The allowlist can be changed while the endpoint is running. The endpoint
checks if the file changed at most once per second (see
Allowlist) so a removed peer is
denied access within about a second.
RELOAD_INTERVAL
module-attribute
¶
Default minimum seconds between checks for changes to the peers file.
PeersConfig
¶
Bases: VersionedFile
Allowlist of peer endpoints.
Attributes:
-
version(int) –Format version of the peers file.
-
peers(dict[str, EndpointId]) –Mapping of peer names to endpoint IDs. Names are only used to help users manage the allowlist.
Raises:
-
ValueError–If a name does not contain only alphanumeric, dash, or underscore characters, if an endpoint ID is invalid, if an endpoint ID is listed more than once, or if the version is not supported.
name_of
¶
name_of(endpoint_id: EndpointId) -> str | None
Get the name of the peer with the endpoint ID.
Peers
¶
Peers(path: str, *, owner_id: EndpointId | None = None)
Peers of an endpoint stored in its peers.toml file.
Example
Parameters:
-
path(str) –Path to the
peers.tomlfile. -
owner_id(EndpointId | None, default:None) –ID of the endpoint which owns the peers. Used to prevent an endpoint from adding itself as a peer.
Source code in proxystore/endpoint/peers.py
read
¶
read() -> PeersConfig
Read the peers.
Returns:
-
PeersConfig–The peers or no peers if the file does not exist.
Raises:
-
EndpointConfigError–If the file cannot be parsed or is invalid.
Source code in proxystore/endpoint/peers.py
write
¶
write(peers: PeersConfig) -> None
add
¶
add(name: str, endpoint_id: str) -> EndpointId
Add a peer.
Parameters:
Returns:
-
EndpointId–The ID of the peer.
Raises:
-
PeerExistsError–If a peer with the name already exists.
-
EndpointConfigError–If the name or ID is invalid, the ID is the ID of the owner, the endpoint is already a peer with a different name, or the file cannot be parsed.
Source code in proxystore/endpoint/peers.py
remove
¶
remove(name: str) -> EndpointId
Remove a peer.
If the endpoint is running, the peer is denied access within about
a second (see Allowlist).
Parameters:
-
name(str) –Name of the peer.
Returns:
-
EndpointId–The ID of the removed peer.
Raises:
-
PeerNotFoundError–If there is no peer with the name.
-
EndpointConfigError–If the file cannot be parsed.
Source code in proxystore/endpoint/peers.py
Allowlist
¶
Allowlist(
path: str, *, reload_interval: float = RELOAD_INTERVAL
)
Allowlist of peer endpoints backed by a peers.toml file.
This is the
PeerPolicy of endpoints.
The file is reloaded when it changes. A missing file is an empty
allowlist. If the file is malformed, all peers are denied until it is
fixed.
Checking if the file changed requires a stat() call which can be slow
on network file systems, so the file is checked at most once every
reload_interval seconds rather than on every request.
Parameters:
-
path(str) –Path to the
peers.tomlfile. -
reload_interval(float, default:RELOAD_INTERVAL) –Minimum seconds between checks for changes to the file. If
0, the file is checked each time the allowlist is used.
Source code in proxystore/endpoint/peers.py
reload
¶
reload(*, force: bool = False) -> None
Reload the allowlist if the file changed.
Parameters:
-
force(bool, default:False) –Check if the file changed even if the reload interval has not passed since the last check.
Source code in proxystore/endpoint/peers.py
allowed
¶
allowed(endpoint_id: EndpointId) -> bool
name_of
¶
name_of(endpoint_id: EndpointId) -> str | None