OxL Reference

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✓ checked in 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()?}")
}
Output
1
pub(api) fn declare(name: str, partitions: i64, retain: Duration, retainCount: i64, modes: i64) -> i64

Complexity. O(1) for a known name.

Thread safety. safe from any task; declaring the same name twice gives the same handle.

Since. 1.0.0-beta

Parameters

NameType
namestr
partitionsi64
retainDuration
retainCounti64
modesi64

Returns

i64

Effects

none declared (pure unless the body says otherwise)

Defined in: std/topic/topic.oxl:121

See also