fn subscribeKeyOf
A broadcast subscription limited to the elements with one sharding key. The generated T.subscribeKey(key) calls it.
Example:
data OrderEvent {
userId: u64
seq: i64
}
topic OrderEvents: OrderEvent sharded by .userId
cluster demo {
role store { journal }
}
fn main() -> () | TopicError io, db {
OrderEvents.publish(OrderEvent{ userId: 1, seq: 10 })?
OrderEvents.publish(OrderEvent{ userId: 2, seq: 20 })?
for await e in OrderEvents.subscribeKey(2 as u64, from: .Earliest) {
print("{e.seq}")
break
}
}Output
20
pub(api) fn subscribeKeyOf<T: Serializable, K: Serializable>(h: i64, key: &K, from: TopicStart?) -> stream<T, TopicError> dbSince. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
h | i64 |
key | &K |
from | TopicStart? |
Returns
stream<T, TopicError>
Effects
db
Defined in: std/topic/topic.oxl:519