Bloccs.Pipeline (bloccs v0.1.0)

Copy Markdown View Source

Runtime helpers called from compiler-emitted Broadway pipelines.

Centralizes the policy decisions the compiler doesn't need to know about (whether to schema-validate, what to do on mismatch) so they can change without re-running mix bloccs.compile.

Summary

Types

Reasons returned by validate_inbound/3 when validation fails.

Functions

Returns true when runtime inbound validation is enabled.

Validate a payload entering port against the schema declared on that port in the node's manifest.

Types

validation_error()

@type validation_error() ::
  {:schema_mismatch, String.t(), [String.t()]}
  | {:unknown_port, atom()}
  | {:payload_not_map, term()}

Reasons returned by validate_inbound/3 when validation fails.

Functions

enabled?()

@spec enabled?() :: boolean()

Returns true when runtime inbound validation is enabled.

validate_inbound(manifest, port, payload)

@spec validate_inbound(Bloccs.Manifest.Node.t(), atom(), term()) ::
  :ok | {:error, validation_error()}

Validate a payload entering port against the schema declared on that port in the node's manifest.

  • Returns :ok if validation is disabled (config :bloccs, :validate_inbound, false), if the port has no schema, or if the schema isn't registered.
  • Returns {:error, reason} if the payload doesn't match.

v0.1 only validates inbound. Outbound payloads are validated implicitly when they reach the next node's inbound check.