### Define Project Boundaries Source: https://github.com/sasa1977/boundary/blob/master/README.md This example demonstrates how to define module boundaries for a typical Elixir project using the `Boundary` macro. It shows how to specify dependencies between boundaries and which modules are exported. ```elixir defmodule MySystem do use Boundary, deps: [], exports: [] # ... end defmodule MySystemWeb do use Boundary, deps: [MySystem], exports: [Endpoint] # ... end defmodule MySystem.Application do use Boundary, top_level?: true, deps: [MySystem, MySystemWeb] # ... end ``` -------------------------------- ### Global Configuration for External App Calls Source: https://github.com/sasa1977/boundary/blob/master/README.md This example shows how to configure Boundary globally in `mix.exs` to enforce rules on calls to external applications that do not define their own boundaries, such as restricting Phoenix or Ecto usage. ```elixir defmodule MySystem.MixProject do use Mix.Project def project do [ # ... # Example: Enforce rules for external apps globally # boundary: [check_apps: [:phoenix, :ecto]] # ... ] end # ... end ``` -------------------------------- ### Configure Boundary Checks in mix.exs Source: https://github.com/sasa1977/boundary/blob/master/README.md This snippet shows how to configure Boundary checks within the `mix.exs` file. It specifies which applications and modules Boundary should monitor at compile-time and runtime. In this example, Boundary checks calls to Phoenix, Ecto, and runtime calls to Mix. ```elixir defmodule MySystem.MixProject do def project do [ boundary: [ default: [ check: [ apps: [:phoenix, :ecto, {:mix, :runtime}] ] ] ], # ... ] end end ``` -------------------------------- ### Example of Forbidden Reference Warning Source: https://github.com/sasa1977/boundary/blob/master/README.md This Elixir code snippet shows a scenario where a module in `MySystem` attempts to call a function from `MySystemWeb`. The Boundary compiler would detect this as a forbidden reference and emit a warning during compilation. ```elixir defmodule MySystem.User do def auth do MySystemWeb.Endpoint.url() end end ``` -------------------------------- ### Define Module Boundaries with Boundary Source: https://github.com/sasa1977/boundary/blob/master/README.md These examples demonstrate how to use the `use Boundary` macro in Elixir modules to declare dependencies. Each module specifies the external dependencies it is allowed to interact with using the `deps` option. For instance, `MySystemWeb` depends on `Phoenix` and `Ecto.Changeset`, while `MySystem` depends on `Ecto` and `Ecto.Changeset`. ```elixir defmodule MySystemWeb do use Boundary, deps: [Phoenix, Ecto.Changeset] end defmodule MySystem do use Boundary, deps: [Ecto, Ecto.Changeset] end defmodule MySystemMix do use Boundary, deps: [Mix] end ``` -------------------------------- ### Integrate Boundary Mix Compiler Source: https://github.com/sasa1977/boundary/blob/master/README.md This code snippet illustrates how to include the Boundary compiler in the project's compilation process by adding `:boundary` to the `compilers` list in `mix.exs`. ```elixir defmodule MySystem.MixProject do use Mix.Project def project do [ compilers: [:boundary] ++ Mix.compilers(), # ... ] end # ... end ``` -------------------------------- ### Add Boundary Dependency in mix.exs Source: https://github.com/sasa1977/boundary/blob/master/README.md This snippet shows how to add the Boundary library as a project dependency in the `mix.exs` file. It specifies the version and sets `runtime: false` as Boundary is a compile-time tool. ```elixir defmodule MySystem.MixProject do use Mix.Project # ... defp deps do [ {:boundary, "~> 0.10", runtime: false}, # ... ] end # ... end ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.