OxL Справочник OxL
РусскийEnglish

data ClusterApi

The cluster as seen from a program that did not import std.cluster (cluster.self(), cluster.leader(…) { … }); use std.cluster brings the same functions as a module.

Example:

oxl✓ проверяется в CI
fn main() io {
  print("{cluster.nodes().len() >= 1}")
}
Вывод
true
@derive(Copy)
pub(api) data ClusterApi

Потокобезопасность. safe from any task; the object has no state of its own.

С версии. 1.0.0-beta

Поля

pub(api) ids: ClusterIds

cluster.ids.next() (§12.6).

Методы

self() -> NodeId
The id of this node.
node(name: str) -> NodeId
The id of the node called name; on a single node every other id is unreachable.
selfInfo() -> ClusterMember
This node as the registry sees it
nodes() -> List<ClusterMember>
All nodes the membership knows, this one included (§12.3); dead and departed ones stay listed for a while with their state.
members() -> List<ClusterMember>
The members that are alive or merely suspected (§12.3 cluster.members()).
leader(name: str, body: fn() F)
Registers the leader task name (§12.6) and returns at once.
now() -> Hlc
cluster.now() (§12.6, §17.3)
observe(h: Hlc) -> bool
Merges a stamp received through application data.
shards() -> List<ShardInfo>
The shard groups of the cluster
lock(key: str, ttl: Duration, wait: Duration, body: fn() -> T F) -> T | LockTimeout | NetError net, time, F
cluster.lock(key, ttl
lockFenced(key: str, ttl: Duration, wait: Duration, body: fn(Fence) -> T F) -> T | LockTimeout | NetError net, time, F
Like lock; the body receives the fencing token of this holding
isLeader(name: str) -> bool
Whether this node currently holds the leadership of the task name (always true outside a cluster).
hasRole(role: str) -> bool
Whether this node has the role role (§12.6 cluster.self.hasRole; all matches every role).
find(name: str) -> List<ClusterMember>
The live nodes that serve the service name (fully qualified pkg.Service or the type name), §12.3.
findRole(role: str) -> List<ClusterMember>
The live nodes that have the role role.
pick(name: str, by: PickBy, prefer: Prefer) -> ClusterMember?
One node that serves name
on(event: ClusterEvent, handler: fn(ClusterMember) F)
Calls handler(member) when the membership changes in the way event names (polled twice a second; changes that happened before the call are not reported).

Определено в: std/core/node.oxl:235

См. также