pymap.cluster
¶
- class pymap.cluster.MemberInterface(*args, **kwargs)[source]¶
A hashable type that represents a cluster member node.
- class pymap.cluster.ListenCallback(*args, **kwargs)[source]¶
- class pymap.cluster.ClusterMetadata(init=None, /)[source]¶
Keeps a mapping of metadata pertaining to the current instance and possibly other clustered instances, if the current instance is part of a cluster.
The object also acts as a set of
MemberInterface
objects. The cluster service should add new or updated members and discard them as they go offline.- Parameters:
init (Collection[MemberInterface] | None) – Initial remote cluster members.
- add(member)[source]¶
Add an element.
- Parameters:
member (MemberInterface)
- Return type:
None
- discard(member)[source]¶
Remove an element. Do not raise an exception if absent.
- Parameters:
member (MemberInterface)
- Return type:
None
- property local: MutableMapping[str, bytes]¶
The local cluster instance metadata. Keys added, removed, and modified in this mapping should be disseminated to the rest of the cluster.
- property remote: Mapping[str, Mapping[MemberInterface, bytes]]¶
The remote cluster instance metadata, organized by metadata key.
- listen(callback, arg)[source]¶
Adds a callback to be run whenever the local metadata has been modified. Cluster services can use this to disseminate metadata changes.
Note
The arg object is weakly referenced, and the callback will be automatically removed if it is garbage-collected.
- Parameters:
callback (ListenCallback[ArgT]) – Function called with the updated local metadata mapping.
arg (ArgT) – The first argument passed to callback.
- Return type:
None