OxL Reference

fn countOf

The number of elements the topic still holds (retention removes the older ones). The generated T.count() calls it.

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 })?
  Jobs.publish(Job{ id: 2 })?
  print("{Jobs.count()?}")
}
Output
2
pub(api) fn countOf(h: i64) -> i64 | TopicError  db

Complexity. O(partitions).

Since. 1.0.0-beta

Parameters

NameType
hi64

Returns

i64

Errors

  • TopicError @error
  • `TopicError` when the store is not reachable.

Effects

db

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

See also