OxL Reference

12.7 Dependencies

oxl
provide Db = Db.open(App.get().dbUrl)          for role api, saga
provide Payments = PaymentsClient.new(App.get().stripeKey)

impl Orders { dep db: Db; dep pay: Payments }
  • provide Type = expression (for role r, …)? — a dependency factory, executed once per node at start-up (step 4 of §2.4) for the listed roles (all by default).
  • dep name: Type is allowed in the impl of a service, in an actor, a pipeline, a saga and at module level. A module-level dependency is available to all functions of the module as an immutable value.

Implementation-defined. Module-level dep (D-8055; DIV-017; D-5101). This implementation binds a module-level dep only in the sagas and pipelines of the module; it is not available in main and in ordinary functions. The other places of dep (service impl, actor) are as in the Standard.

  • If code that uses a dep can run on a role without the corresponding provide, it is a compile error. A test MAY override a provide (§18).

duplicate-provide, missing-provide, unknown-role

See also

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