OxL Reference

IV.1 No "magic" values

Timeouts, retries, sizes, limits, TTLs and thresholds are set once by a named constant or a config field and reused. A literal in an attribute is allowed only if it occurs in the program once and its meaning is obvious from the context (analyzer: magic-literal).

Bad:

oxl
@timeout(3s) rpc get(id: UserId) -> User
@timeout(3s) rpc list(page: u32) -> List<User>
@timeout(3s) @retry(3) rpc create(…) -> User

Good:

oxl
// src/limits/limits.oxl — a single place for default values
pub const STD_TIMEOUT    = 3s
pub const LONG_TIMEOUT   = 30s
pub const STD_RETRIES    = 3
pub const PAGE_SIZE: u32 = 50

@timeout(STD_TIMEOUT) rpc get(id: UserId) -> User
@timeout(STD_TIMEOUT) rpc list(page: u32) -> List<User>
@timeout(STD_TIMEOUT) @retry(STD_RETRIES) @idempotent rpc create(…) -> User

Even better — set the common value in cluster { defaults { timeout STD_TIMEOUT } } and write @timeout only where the value differs.

Where to put a value:

ValueWhere
known at build time and independent of the environmenta const in the module limits or next to its use
depends on the environment (addresses, keys, ports)config (§14.1)
changes at run time without a restart (limits, flags)dynamic (§14.2)
the same for all rpcs of the clustercluster { defaults { … } }

magic-literal

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