OxL Reference

fn publishOf

Stores one element of a topic and returns when the store has accepted it. The generated T.publish(x) calls it.

Example:

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

topic Jobs: Job

cluster demo {
  role store { journal }
}

fn main() io, db {
  match Jobs.publish(Job{ id: 1 }) {
    TopicError e => print("not stored: {e.msg}")
    _ => print("stored")
  }
}
Output
stored
pub(api) fn publishOf<T: Serializable>(h: i64, x: &T, key: bytes) -> () | TopicError  db

Complexity. O(size of the element) plus one replicated write.

Since. 1.0.0-beta

Parameters

NameType
hi64
x&T
keybytes

Returns

()

Errors

  • TopicError @error
  • `TopicError` (`Unavailable` nothing was stored, `Unknown` the outcome is unknown, `AccessDenied` the policy refuses, `Other` the element cannot be encoded).

Effects

db

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

See also