Liking cljdoc? Tell your friends :D

wagoe.platform.shell.service-interceptors

Service-level interceptors for business logic operations.

This namespace provides interceptor pipelines specifically designed for service layer operations, eliminating manual observability calls and providing consistent error handling, logging, metrics, and error reporting across all service methods.

Key Benefits:

  • Eliminates 50+ manual observability calls from service methods
  • Provides consistent error handling and reporting patterns
  • Automatic timing, logging, and metrics collection
  • Single point of control for service-level cross-cutting concerns

Usage: (execute-service-operation :register-user {:user-data user-data :tenant-id tenant-id} service-impl-fn {:system system})

Architecture:

  • Service interceptors wrap pure business logic functions
  • Context carries operation metadata and observability services
  • Interceptors handle all cross-cutting concerns automatically
Service-level interceptors for business logic operations.

This namespace provides interceptor pipelines specifically designed for service layer operations,
eliminating manual observability calls and providing consistent error handling, logging, metrics,
and error reporting across all service methods.

Key Benefits:
- Eliminates 50+ manual observability calls from service methods
- Provides consistent error handling and reporting patterns
- Automatic timing, logging, and metrics collection
- Single point of control for service-level cross-cutting concerns

Usage:
  (execute-service-operation 
    :register-user 
    {:user-data user-data :tenant-id tenant-id}
    service-impl-fn
    {:system system})

Architecture:
- Service interceptors wrap pure business logic functions
- Context carries operation metadata and observability services
- Interceptors handle all cross-cutting concerns automatically
raw docstring

base-service-pipelineclj

Base interceptor pipeline for all service operations.

Base interceptor pipeline for all service operations.
sourceraw docstring

create-service-contextclj

(create-service-context operation params system & [metadata])

Creates a service interceptor context for business logic operations.

Args: operation: Keyword identifying the service operation (e.g., :register-user) params: Map of operation parameters system: Map containing observability services {:logger :metrics-emitter :error-reporter} metadata: Optional additional metadata

Returns: Service context map with operation details and observability services

Creates a service interceptor context for business logic operations.

Args:
  operation: Keyword identifying the service operation (e.g., :register-user)
  params: Map of operation parameters
  system: Map containing observability services {:logger :metrics-emitter :error-reporter}
  metadata: Optional additional metadata

Returns:
  Service context map with operation details and observability services
sourceraw docstring

create-service-pipelineclj

(create-service-pipeline business-logic-fn & custom-interceptors)

Creates a service interceptor pipeline with business logic.

Args: business-logic-fn: Function that implements the actual business logic custom-interceptors: Optional additional interceptors to include

Returns: Complete interceptor pipeline for service operation

Creates a service interceptor pipeline with business logic.

Args:
  business-logic-fn: Function that implements the actual business logic
  custom-interceptors: Optional additional interceptors to include

Returns:
  Complete interceptor pipeline for service operation
sourceraw docstring

defservicecljmacro

(defservice name args context-map & body)

Defines a service method with automatic interceptor pipeline.

Example: (defservice register-user [this user-data] {:operation :register-user :params {:user-data user-data :tenant-id (:tenant-id user-data)} :system (extract-system this)} ;; Business logic here (let [prepared-user (user-core/prepare-user-for-creation user-data)] (.create-user (:user-repository this) prepared-user)))

Defines a service method with automatic interceptor pipeline.

Example:
  (defservice register-user [this user-data]
    {:operation :register-user
     :params {:user-data user-data :tenant-id (:tenant-id user-data)}
     :system (extract-system this)}
    ;; Business logic here
    (let [prepared-user (user-core/prepare-user-for-creation user-data)]
      (.create-user (:user-repository this) prepared-user)))
sourceraw docstring

execute-service-operationclj

(execute-service-operation operation
                           params
                           business-logic-fn
                           system
                           &
                           [options])

Executes a service operation using interceptor pipeline with automatic observability.

This is the single method to use for all service operations. It automatically handles:

  • Error reporting and breadcrumbs
  • Logging (info, error, audit, business events)
  • Metrics (timing, counters, success/failure tracking)
  • Exception handling and re-throwing

Args: operation: Keyword identifying the operation (e.g., :register-user) params: Map of operation parameters business-logic-fn: Function implementing the pure business logic system: Map with observability services {:logger :metrics-emitter :error-reporter} options: Optional map with {:custom-interceptors [...] :metadata {...}}

Returns: Result of the business logic function

Example: (execute-service-operation :register-user {:user-data user-data :tenant-id tenant-id} (fn [{:keys [params]}] ;; Pure business logic here (let [user-data (:user-data params)] ;; ... implement registration logic created-user)) {:logger logger :metrics-emitter metrics :error-reporter error-reporter})

Executes a service operation using interceptor pipeline with automatic observability.

This is the single method to use for all service operations. It automatically handles:
- Error reporting and breadcrumbs
- Logging (info, error, audit, business events)  
- Metrics (timing, counters, success/failure tracking)
- Exception handling and re-throwing

Args:
  operation: Keyword identifying the operation (e.g., :register-user)
  params: Map of operation parameters
  business-logic-fn: Function implementing the pure business logic
  system: Map with observability services {:logger :metrics-emitter :error-reporter}
  options: Optional map with {:custom-interceptors [...] :metadata {...}}

Returns:
  Result of the business logic function

Example:
  (execute-service-operation 
    :register-user 
    {:user-data user-data :tenant-id tenant-id}
    (fn [{:keys [params]}]
      ;; Pure business logic here
      (let [user-data (:user-data params)]
        ;; ... implement registration logic
        created-user))
    {:logger logger :metrics-emitter metrics :error-reporter error-reporter})
sourceraw docstring

service-audit-loggingclj

Handles service operation audit logging for compliance.

Handles service operation audit logging for compliance.
sourceraw docstring

service-error-handlingclj

Handles service operation error reporting and recovery.

Handles service operation error reporting and recovery.
sourceraw docstring

service-operation-loggingclj

Handles service operation logging throughout the lifecycle.

Handles service operation logging throughout the lifecycle.
sourceraw docstring

service-operation-metricsclj

Handles service operation metrics collection.

Handles service operation metrics collection.
sourceraw docstring

service-operation-startclj

Initializes service operation with observability setup.

Initializes service operation with observability setup.
sourceraw docstring

service-success-breadcrumbclj

Adds success breadcrumb for successful operations.

Adds success breadcrumb for successful operations.
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