kw role
Contextual keyword — cluster declaration (§12.1)
The list of words: §1.4
Syntax
Provide = "provide" Type "=" Expr [ "for" "role" IdentList ] ;ClusterClause = "seeds" Expr | "port" IntLit | "trace_sample" FloatLit | "auth" Block | "defaults" "{" { Ident Expr } "}"
| "role" Ident "{" RoleClause { ( ";" | NL ) RoleClause } "}"
| "assign" "by" Expr { "else" Expr } ;Grammar: App. A
Defined in
- 12.1 Cluster declaration — A program has at most one cluster.
- 4.2 data — A field: visibility?
- 13.4 Authorisation and policies — The subject of a policy
- 1.4 Keywords — Reserved (cannot be used as names)
- 10.6 Pipelines — A pipeline is a linear chain of steps, each of which runs on its own node; data is passed from node to node directly, the caller receives on
- 12.7 Dependencies — provide Type = expression (for role r, …)?
- 13.2 Authentication — Providers are set in cluster { auth { …
- 5.4 Conditions — There is no ternary operator.
Examples
pub(api) data User {
pub(api) id: UserId
pub(api) name: Name
pub(api) email: Email? @since(2)
role: Role = Role.User
createdAt: Time = now()
invariant name != "admin" || role == Role.Admin
}— 4.2 data
policy Orders {
allow get(id) if caller.isUser(db.find(Order, id)?.userId)
allow list, recent if caller.has(role: .Support)
allow * if caller.service("billing")
deny delete unless caller.has(role: .Admin) && caller is .User(mfa: true, ..)
}
@public rpc health() -> Ok
@allow(role: .Admin) rpc purge() -> Ok
@internal rpc create(…) -> Order— 13.4 Authorisation and policies
Related diagnostics
actor-not-hosted, cluster-auth, cluster-decl, cluster-needs, cluster-seeds, placement-conflict, saga-without-role, service-not-served, topic-without-journal, unknown-role, unknown-field, data-rights, missing-policy, unknown-policy-target