fn publishOf
Stores one element of a topic and returns when the store has accepted it. The generated T.publish(x) calls it.
Example:
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 dbComplexity. O(size of the element) plus one replicated write.
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
h | i64 |
x | &T |
key | bytes |
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