kw sharded
Contextual keyword — actor declaration (§12.5), topic declaration (§10.5)
The list of words: §1.4
Syntax
Actor = "actor" Ident [ "sharded" "by" Ident ":" Type ] "{" { ActorMember } "}" ;Topic = "topic" Ident ":" Type [ "sharded" "by" FieldPath ] ;Grammar: App. A
Defined in
- 10.5 Topics — cluster-wide fan-out — A topic is a distributed broadcast with storage in the built-in storage.
- 12.5 Sharded actors — The key is declared in the header (sharded by name
- 1.4 Keywords — Reserved (cannot be used as names)
- 13.4 Authorisation and policies — The subject of a policy
Examples
@retain(ORDER_EVENTS_RETENTION)
topic OrderEvents: OrderEvent sharded by .userId
emit OrderEvents(e) // publication
for await e in OrderEvents.subscribe(key: uid, from: .Latest) { … }
for await e in OrderEvents.subscribe(group: "indexer") { index(e) }— 10.5 Topics — cluster-wide fan-out
@idle(ACCOUNT_IDLE)
actor Account sharded by id: AccountId {
var balance: Money = Money.zero()
@transient var hits: u64 = 0
on activate { log.debug("account {id} up") }
msg deposit(x: Money) { balance += x }
msg balance() -> Money { balance }
}
Account(id).deposit(amount)Related diagnostics
topic-without-journal, actor-not-hosted, data-rights, missing-policy, unknown-policy-target