OxL Reference

method ClusterApi.pick

One node that serves name: the least loaded one (by: .LeastLoad), or the first (.First); prefer: .SameZone limits the choice to this node's zone when there is a node in it (§12.3).

Example:

oxl✓ checked in CI
fn main() io {
  match cluster.pick("Bank", by: .LeastLoad, prefer: .SameZone) {
    ClusterMember m => print("use {m.id.name}")
    none => print("nobody serves Bank")
  }
}
Output
nobody serves Bank
pub(api) fn pick(name: str, by: PickBy = .LeastLoad, prefer: Prefer = .Any) -> ClusterMember?

Since. 1.0.0-beta

Parameters

NameType
namestr
byPickBy = .LeastLoad
preferPrefer = .Any

Returns

ClusterMember?

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/node.oxl:539

See also