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

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:

oxl✓ проверяется в CI
fn main() io, time {
  cluster.leader("cleanup") {
    print("this node leads cleanup")
  }
  sleep(100ms)
}
Вывод
this node leads cleanup
pub(api) fn leader<effect F>(name: str, body: fn() F)

С версии. 1.0.0-beta

Параметры

ИмяТип
namestr
bodyfn() F

Эффекты

не объявлены (чистая, пока тело не говорит иное)

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

См. также