method ClusterApi.leader
Registers the leader task name (§12.6) and returns at once. Without a cluster this node is the leader of every task and body
starts in the background scope of the node. In a cluster one node holds the lease of name (coordinator, D-4585): body runs
there, in the background scope, and is cancelled when the node loses the lease; the other nodes wait for it.
Example:
fn main() io, time {
cluster.leader("cleanup") {
print("this node leads cleanup")
}
sleep(100ms)
}Output
this node leads cleanup
pub(api) fn leader<effect F>(name: str, body: fn() F)Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
name | str |
body | fn() F |
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/node.oxl:336