View Source Agens.Router.Condition (agens v0.2.0)

A boolean comparison against a structured Router output value.

Conditions are typically used by a Router's Agens.Router.resolve/2 implementation to branch on the structured outputs produced by a Serving. The :value declared on the condition is coerced to the output's :type before comparison.

Fields

  • :key - The Agens.Router.Output key to inspect.
  • :op - One of "eq", "neq", "gt", "lt", "gte", "lte".
  • :value - The literal value to compare against (as a string; coerced based on the output's type).

Summary

Functions

Evaluates the condition against a list of Agens.Router.Output values.

Types

@type t() :: %Agens.Router.Condition{
  key: String.t(),
  op: String.t(),
  value: String.t() | nil
}

Functions

Link to this function

check(condition, outputs)

View Source
@spec check(t(), [Agens.Router.Output.t()]) :: boolean()

Evaluates the condition against a list of Agens.Router.Output values.

Returns false if the key is missing or the resolved value is nil. Otherwise compares using the condition's :op after coercing the condition's :value to match the output's declared type.