Discovery
Discovery and gossip helpers.
determine_best_node(preference, members)
Selects the best node, given a preference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
preference |
gossip_pb2.MemberInfo.VNodeState
|
the type of node that you want to choose (e.g. |
required |
members |
Iterable[gossip_pb2.MemberInfo]
|
a list of nodes (as gossip_pb2.MemeberInfo objects) to choose from. |
required |
Returns:
| Type | Description |
|---|---|
gossip_pb2.MemberInfo
|
The selected node from members, of None if none of the objects satisfies the |
gossip_pb2.MemberInfo
|
requested preference. |
Source code in src/eventstore_grpc/discovery.py
discover_endpoint(candidates, credentials=None, max_discovery_attempts=10, vnode_state=gossip_pb2.MemberInfo.Leader)
Discovers an endpoint to connect to.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidates |
List
|
a list of candidates nodes to use for discovery. |
required |
credentials |
grpc.ChannelCredentials
|
the channel credentials to use for listing cluster members. |
None
|
max_discovery_attempts |
int
|
the maximum number of discovery attempts that will be made to determine the best node. |
10
|
Returns:
| Type | Description |
|---|---|
str
|
The url of the selected node. |
Raises:
| Type | Description |
|---|---|
Exception
|
when it's not possible to match any node. |
Source code in src/eventstore_grpc/discovery.py
list_cluster_members(uri, credentials)
Lists cluster memeber using the provided uri to connect to the cluster.
You can use this function to get information about the nodes in the cluster. The MemberInfo objects returned can give information like the state of the node (Initializing, Leader, ...), the instance id, is_alive, and the endpoint of the node (address, port).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri |
str
|
the URI that will be used to connect to the node. |
required |
credentials |
grpc.ChannelCredentials
|
the ChannelCredentials to use to connect to the node. |
required |
Returns:
| Type | Description |
|---|---|
Iterable[gossip_pb2.MemberInfo]
|
The nodes information as gossip_pb2.MemberInfo objects. |