How boundaries and module exports work
masterA boundary is a named group of one or more modules. Boundary automatically determines which modules belong to a boundary based on the boundary's name. For example, a boundary named MySystem includes the MySystem module and any module starting with MySystem. (e.g., MySystem.User).
Each boundary defines:
deps: A list of other boundaries that this boundary is allowed to depend on.exports: A list of specific modules within this boundary that are visible to other boundaries. If a module is not listed inexports, other boundaries cannot invoke its functions.top_level?: (Optional) Used in application modules to define them as top-level boundaries.
During compilation, the boundary compiler reports any cross-module function calls that violate these rules.
# Example of defining boundaries
defmodule MySystem do
use Boundary, deps: [], exports: []
end
defmodule MySystemWeb do
# MySystemWeb can depend on MySystem, but only access the Endpoint module
use Boundary, deps: [MySystem], exports: [Endpoint]
end
defmodule MySystem.Application do
# Top level boundary allowed to depend on both
use Boundary, top_level?: true, deps: [MySystem, MySystemWeb]
end