OxL Reference

12.5 Sharded actors

oxl
@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)
  • The key is declared in the header (sharded by name: Type) and is available in the body as an immutable field.
  • Account(key) is an ActorRef<Account>; the actor is activated on the first message on the node that owns the shard. At most one instance per key is active in the cluster at a time.
  • var fields are saved to the journal after each message, before the reply is sent; @transient var fields are not saved. On activation the state is restored, otherwise the defaults are used; then on activate is executed.
  • @idle(d) unloads the actor after d without messages (on passivate before unloading).
  • The semantics of message processing — §8.8. When a shard moves, the runtime repeats delivery; state-changing messages SHOULD be made idempotent.
  • In tests Account.local(key) creates an instance in the process without a cluster.

Implementation-defined. Deduplication of actor messages (D-8055; DIV-018; D-4899). The Standard requires at-least-once with deduplication but does not define its bounds. This implementation: the deduplication window is the last 64 messages; the marks do not expire by time (IDEMPOTENCY_TTL does not apply to actor messages); there is no @mailbox attribute (queue size).

actor-not-hosted

See also

Source: docs/spec/oxl-standard.en.md