Liking cljdoc? Tell your friends :D

boundary.core.interceptor

Core interceptor pipeline execution engine.

Provides a lightweight interceptor chain pattern for handling cross-cutting concerns like logging, metrics, validation, and error handling in a declarative way.

Interceptors have three lifecycle functions:

  • :enter - executed in forward order during pipeline execution
  • :leave - executed in reverse order during successful completion
  • :error - executed in reverse order when an exception occurs

The context map is threaded through all interceptors and contains:

  • :request - original request data
  • :op - operation identifier (keyword)
  • :system - dependency injection map
  • :correlation-id - request correlation ID
  • :halt? - flag to short-circuit pipeline execution
  • other keys added by interceptors during execution
Core interceptor pipeline execution engine.

Provides a lightweight interceptor chain pattern for handling cross-cutting
concerns like logging, metrics, validation, and error handling in a
declarative way.

Interceptors have three lifecycle functions:
- :enter - executed in forward order during pipeline execution
- :leave - executed in reverse order during successful completion
- :error - executed in reverse order when an exception occurs

The context map is threaded through all interceptors and contains:
- :request - original request data
- :op - operation identifier (keyword)
- :system - dependency injection map
- :correlation-id - request correlation ID
- :halt? - flag to short-circuit pipeline execution
- other keys added by interceptors during execution
raw docstring

create-pipelineclj

(create-pipeline interceptors)

Creates and validates a pipeline of interceptors.

Creates and validates a pipeline of interceptors.
sourceraw docstring

execute-interceptor-fnclj

(execute-interceptor-fn interceptor-fn ctx interceptor-name)

Safely executes an interceptor function with error handling.

IMPORTANT: Preserve domain exceptions (ExceptionInfo with ex-data) so that their :type/:message/:violations are still visible to higher-level handlers. Only wrap non-ExceptionInfo throwables for additional interceptor context.

Safely executes an interceptor function with error handling.

IMPORTANT: Preserve domain exceptions (ExceptionInfo with ex-data) so that
their :type/:message/:violations are still visible to higher-level handlers.
Only wrap non-ExceptionInfo throwables for additional interceptor context.
sourceraw docstring

get-from-contextclj

(get-from-context ctx key-path)
(get-from-context ctx key-path default)

Helper function to safely get values from context.

Helper function to safely get values from context.
sourceraw docstring

halt-pipelineclj

(halt-pipeline ctx)
(halt-pipeline ctx response-data)

Helper function to halt pipeline execution with optional response data.

Helper function to halt pipeline execution with optional response data.
sourceraw docstring

run-enter-phaseclj

(run-enter-phase initial-ctx interceptors)

Executes the :enter phase of interceptors in forward order. Returns [final-context executed-stack exception] where executed-stack contains interceptors that successfully executed their :enter function. If an exception occurs, it returns [partial-context partial-executed-stack exception].

Executes the :enter phase of interceptors in forward order.
Returns [final-context executed-stack exception] where executed-stack contains
interceptors that successfully executed their :enter function.
If an exception occurs, it returns [partial-context partial-executed-stack exception].
sourceraw docstring

run-error-phaseclj

(run-error-phase ctx executed-stack exception)

Executes the :error phase of interceptors in reverse order when an exception occurs.

Executes the :error phase of interceptors in reverse order when an exception occurs.
sourceraw docstring

run-leave-phaseclj

(run-leave-phase ctx executed-stack)

Executes the :leave phase of interceptors in reverse order.

Executes the :leave phase of interceptors in reverse order.
sourceraw docstring

run-pipelineclj

(run-pipeline initial-ctx interceptors)

Executes a pipeline of interceptors with proper lifecycle management.

Args:

  • initial-ctx: Initial context map
  • interceptors: Vector of interceptor maps with :name, :enter, :leave, :error keys

Returns:

  • Final context map after all interceptors have executed

Execution flow:

  1. Execute :enter functions in forward order until halt or completion
  2. If successful, execute :leave functions in reverse order
  3. If exception occurs, execute :error functions in reverse order

Short-circuiting:

  • Any interceptor can set :halt? true in context to stop forward execution
  • :leave functions will still execute for already-executed interceptors
Executes a pipeline of interceptors with proper lifecycle management.

Args:
- initial-ctx: Initial context map
- interceptors: Vector of interceptor maps with :name, :enter, :leave, :error keys

Returns:
- Final context map after all interceptors have executed

Execution flow:
1. Execute :enter functions in forward order until halt or completion
2. If successful, execute :leave functions in reverse order
3. If exception occurs, execute :error functions in reverse order

Short-circuiting:
- Any interceptor can set :halt? true in context to stop forward execution
- :leave functions will still execute for already-executed interceptors
sourceraw docstring

update-contextclj

(update-context ctx key-path value)

Helper function to safely update context with validation.

Helper function to safely update context with validation.
sourceraw docstring

validate-interceptorclj

(validate-interceptor interceptor)

Validates that an interceptor has the required structure.

Validates that an interceptor has the required structure.
sourceraw docstring

validate-pipelineclj

(validate-pipeline interceptors)

Validates a pipeline of interceptors.

Validates a pipeline of interceptors.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close