Juggernaut.Routing (Juggernaut v0.4.0)

Copy Markdown View Source

Raw, skipped and arid calls (design notes §8.2, §8.4).

  • raw_calls - the call is still a site, but the listed argument positions (all when none are listed) are never walked: Mutare's :raw, used for compile-time DSL macros such as Ecto.Query.from/2;
  • skip_calls - the call, its arguments and the value piped into it are never walked: Mutare's :skip;
  • arid calls, in the inner lane only and never in core code: Logger, IO and :telemetry calls are skipped, the message argument of raise/1,2 is raw, and arid_calls are skipped.

An entry is {Mod, :fun}, {Mod, :fun, arity} or {Mod, :fun, arity, [positions]}; Mod (or :fun) may be :*. A local call matches a module's entry when the module is imported or used by the enclosing module and the call is not to a function the module defines itself; only :* entries match a call to the module's own function. Skip entries are checked before raw ones.

Summary

Functions

Whether arid calls apply anywhere under routing.

Whether entry matches call at ctx.

The routing of a run: raw_calls, skip_calls and arid_calls from opts. Arid calls apply where arid says: true or false for the whole file, or a function of the enclosing module (inner lane: true outside core, whether core is given as files or as modules).

The routing decision for a resolved call, and the entry that decided it.

routing with arid calls turned off: the gate lane's routing of the same file.

Types

arid()

@type arid() :: boolean() | (module() | nil -> boolean())

decision()

@type decision() :: :walk | :skip | {:raw, :all | [non_neg_integer()]}

entry()

@type entry() ::
  {module() | :*, atom()}
  | {module() | :*, atom(), arity()}
  | {module() | :*, atom(), arity(), [non_neg_integer()]}

t()

@type t() :: %Juggernaut.Routing{
  arid: arid(),
  arid_raw: [entry()],
  arid_skip: [entry()],
  raw: [entry()],
  skip: [entry()]
}

Functions

arid?(routing)

@spec arid?(t()) :: boolean()

Whether arid calls apply anywhere under routing.

matches?(entry, call, ctx)

Whether entry matches call at ctx.

new(opts, arid)

@spec new(keyword(), arid()) :: t()

The routing of a run: raw_calls, skip_calls and arid_calls from opts. Arid calls apply where arid says: true or false for the whole file, or a function of the enclosing module (inner lane: true outside core, whether core is given as files or as modules).

route(routing, call, ctx)

The routing decision for a resolved call, and the entry that decided it.

without_arid(routing)

@spec without_arid(t()) :: t()

routing with arid calls turned off: the gate lane's routing of the same file.