Service Layer Reference¶
External API definitions in USL.
Service Definition¶
service MyService {
action createUser(email: Email, name: String) -> User
enforces UserPolicy.can_create
effects { Write(User) }
implementation {
// action logic
}
}
Actions¶
Signature¶
Policy Enforcement¶
Effects¶
Implementation¶
Built-in Functions¶
// Storage
load(Entity, id)
store(entity)
delete(entity)
loadAll(Entity)
// Utilities
generateId()
now()
emit(Event)
Error Handling¶
action risky() -> Result[Data, Error]
implementation {
match externalCall() {
Ok(data) => Ok(data)
Err(e) => Err(MyError.External(e))
}
}