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

fn declare

Declares a topic (idempotent by name) and returns its handle. retain zero = the cluster default (7 days), retainCount zero = no count limit; modes = policy modes (oxl_policy.h): publish | subscribe << 4 | audit << 8 | system << 12.

Example:

oxl✓ проверяется в CI
data Job { id: i64 }

topic Jobs: Job

cluster demo {
  role store { journal }
}

fn main() -> () | TopicError io, db {
  Jobs.publish(Job{ id: 1 })?
  print("{Jobs.count()?}")
}
Вывод
1
pub(api) fn declare(name: str, partitions: i64, retain: Duration, retainCount: i64, modes: i64) -> i64

Сложность. O(1) for a known name.

Потокобезопасность. safe from any task; declaring the same name twice gives the same handle.

С версии. 1.0.0-beta

Параметры

ИмяТип
namestr
partitionsi64
retainDuration
retainCounti64
modesi64

Возвращает

i64

Эффекты

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

Определено в: std/topic/topic.oxl:121

См. также