OxL Reference

fn sweepOf

Applies the retention of the topic now (@retain(...)) and returns the number of elements removed. The generated T.sweep() calls it.

Example:

oxl✓ checked in CI
data Job { id: i64 }

@retain(count: 2)
topic Jobs: Job

cluster demo {
  role store { journal }
}

fn main() -> () | TopicError io, db {
  var i: i64 = 0
  while i < 5 {
    Jobs.publish(Job{ id: i })?
    i += 1
  }
  Jobs.sweep()?
  print("{Jobs.count()?}")
}
Output
2
pub(api) fn sweepOf(h: i64) -> i64 | TopicError  db

Complexity. O(removed elements).

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:483

See also