The PARC evaluation engine: run an ordered list of Parc.RequestPreparer steps
over a Parc.Request, then hand the prepared request to the Parc.PolicyDecider
and return its verdict. Framework-agnostic: a host adapter builds the request
from its own representation and calls run/3; the same declared pipeline serves
every entry point.
A policy module declares its pipeline with use Parc.Pipeline, then runs a
request through its own declared steps with run/1:
defmodule MyApp.Policy do
use Parc.Pipeline
prepare MyApp.Preparers.Telemetry
prepare MyApp.Preparers.IPLocation, key: :ip_location
prepare MyApp.Preparers.Clock, key: :now
decide MyApp.Decider
end
MyApp.Policy.run(request)
Summary
Functions
Declares the pipeline's single Parc.PolicyDecider. Accepts a module or a
{:config, otp_app, key} tuple resolved at compile time. Raises if declared
more than once.
Declares a Parc.RequestPreparer as the next step in the pipeline. Steps run in
declaration order, and opts is passed to the preparer's call/2 at run time.
Runs preparers over request, then the decider. Returns the decider's
Parc.PolicyDecider.response/0, or {:error, reason} if a preparer aborted
(the decider is not consulted).
Functions
Declares the pipeline's single Parc.PolicyDecider. Accepts a module or a
{:config, otp_app, key} tuple resolved at compile time. Raises if declared
more than once.
Declares a Parc.RequestPreparer as the next step in the pipeline. Steps run in
declaration order, and opts is passed to the preparer's call/2 at run time.
@spec run(Parc.Request.t(), [{module(), keyword()}], module()) :: Parc.PolicyDecider.response()
Runs preparers over request, then the decider. Returns the decider's
Parc.PolicyDecider.response/0, or {:error, reason} if a preparer aborted
(the decider is not consulted).