Safe Haskell | None |
---|---|
Language | Haskell2010 |
Temporal.Interceptor
Description
Temporal interceptors allow you to customize and extend the behavior of workflows and activities by intercepting and modifying their execution at various points. Interceptors can be used to add cross-cutting concerns, such as logging, security, or monitoring, to your Temporal applications.
This module provides types and functions for defining and composing interceptors for different parts of Temporal workflows and activities.
Types for different types of interceptors:
WorkflowInboundInterceptor
: An interceptor for workflows, invoked for commands sent to workflow execution.WorkflowOutboundInterceptor
: An interceptor for workflows, invoked for commands sent from a workflow.ActivityInboundInterceptor
: An interceptor for activities, invoked for commands sent to an activity.ActivityOutboundInterceptor
: An interceptor for activities, invoked for actions executed by an activity.ClientInterceptors
: Interceptors for Temporal clients.
Functions for composing interceptors:
interceptorConvertChildWorkflowHandle
: A function for converting child workflow handles within interceptors.
Example usage of interceptors:
- Define a custom interceptor for activities using
ActivityInboundInterceptor
.
myActivityInterceptor :: ActivityInboundInterceptor myActivityInterceptor = ActivityInboundInterceptor { executeActivity = \input next -> do -- Perform custom logic before calling the activity function result <- next input -- Perform custom logic after the activity function completes return result }
- Compose multiple interceptors using
Semigroup
instances.
combinedInterceptor :: Interceptor combinedInterceptor = bugsnagInterceptor <> encryptionInterceptor <> otelInterceptor
- Provide the interceptors to the Temporal Workflow client and worker.
Synopsis
- data Interceptors env = Interceptors {
- workflowInboundInterceptors :: WorkflowInboundInterceptor
- workflowOutboundInterceptors :: WorkflowOutboundInterceptor
- activityInboundInterceptors :: ActivityInboundInterceptor env
- activityOutboundInterceptors :: ActivityOutboundInterceptor env
- clientInterceptors :: ClientInterceptors
- scheduleClientInterceptors :: ScheduleClientInterceptors
- data ExecuteWorkflowInput = ExecuteWorkflowInput {}
- data WorkflowInboundInterceptor = WorkflowInboundInterceptor {
- executeWorkflow :: ExecuteWorkflowInput -> (ExecuteWorkflowInput -> IO (WorkflowExitVariant Payload)) -> IO (WorkflowExitVariant Payload)
- handleQuery :: HandleQueryInput -> (HandleQueryInput -> IO (Either SomeException Payload)) -> IO (Either SomeException Payload)
- data HandleQueryInput = HandleQueryInput {}
- data WorkflowOutboundInterceptor = WorkflowOutboundInterceptor {
- scheduleActivity :: ActivityInput -> (ActivityInput -> IO (Task Payload)) -> IO (Task Payload)
- startChildWorkflowExecution :: Text -> StartChildWorkflowOptions -> (Text -> StartChildWorkflowOptions -> IO (ChildWorkflowHandle Payload)) -> IO (ChildWorkflowHandle Payload)
- continueAsNew :: forall a. Text -> ContinueAsNewOptions -> (Text -> ContinueAsNewOptions -> IO a) -> IO a
- data ActivityInput = ActivityInput {
- activityType :: Text
- args :: Vector Payload
- options :: StartActivityOptions
- seq :: Sequence
- data ActivityInboundInterceptor env = ActivityInboundInterceptor {
- executeActivity :: env -> ExecuteActivityInput -> (env -> ExecuteActivityInput -> IO (Either String Payload)) -> IO (Either String Payload)
- data ExecuteActivityInput = ExecuteActivityInput {}
- data ActivityOutboundInterceptor env = ActivityOutboundInterceptor
- data WorkflowExitVariant a
- data ClientInterceptors = ClientInterceptors {
- start :: WorkflowType -> WorkflowId -> StartWorkflowOptions -> Vector Payload -> (WorkflowType -> WorkflowId -> StartWorkflowOptions -> Vector Payload -> IO (WorkflowHandle Payload)) -> IO (WorkflowHandle Payload)
- queryWorkflow :: QueryWorkflowInput -> (QueryWorkflowInput -> IO (Either QueryRejected Payload)) -> IO (Either QueryRejected Payload)
- signalWithStart :: SignalWithStartWorkflowInput -> (SignalWithStartWorkflowInput -> IO (WorkflowHandle Payload)) -> IO (WorkflowHandle Payload)
- data QueryWorkflowInput = QueryWorkflowInput {}
- data SignalWithStartWorkflowInput = SignalWithStartWorkflowInput {}
- data ScheduleClientInterceptors = ScheduleClientInterceptors {}
- interceptorConvertChildWorkflowHandle :: ChildWorkflowHandle a -> (a -> IO b) -> ChildWorkflowHandle b
Documentation
data Interceptors env Source #
Constructors
Instances
Monoid (Interceptors env) Source # | |
Defined in Temporal.Interceptor Methods mempty :: Interceptors env # mappend :: Interceptors env -> Interceptors env -> Interceptors env # mconcat :: [Interceptors env] -> Interceptors env # | |
Semigroup (Interceptors env) Source # | |
Defined in Temporal.Interceptor Methods (<>) :: Interceptors env -> Interceptors env -> Interceptors env # sconcat :: NonEmpty (Interceptors env) -> Interceptors env # stimes :: Integral b => b -> Interceptors env -> Interceptors env # |
data ExecuteWorkflowInput Source #
Constructors
ExecuteWorkflowInput | |
data WorkflowInboundInterceptor Source #
Constructors
WorkflowInboundInterceptor | |
Fields
|
Instances
data HandleQueryInput Source #
Constructors
HandleQueryInput | |
Fields |
data WorkflowOutboundInterceptor Source #
Constructors
WorkflowOutboundInterceptor | |
Fields
|
Instances
data ActivityInput Source #
Constructors
ActivityInput | |
Fields
|
data ActivityInboundInterceptor env Source #
Constructors
ActivityInboundInterceptor | |
Fields
|
Instances
Monoid (ActivityInboundInterceptor env) Source # | |
Defined in Temporal.Interceptor Methods mempty :: ActivityInboundInterceptor env # mappend :: ActivityInboundInterceptor env -> ActivityInboundInterceptor env -> ActivityInboundInterceptor env # mconcat :: [ActivityInboundInterceptor env] -> ActivityInboundInterceptor env # | |
Semigroup (ActivityInboundInterceptor env) Source # | |
Defined in Temporal.Interceptor Methods (<>) :: ActivityInboundInterceptor env -> ActivityInboundInterceptor env -> ActivityInboundInterceptor env # sconcat :: NonEmpty (ActivityInboundInterceptor env) -> ActivityInboundInterceptor env # stimes :: Integral b => b -> ActivityInboundInterceptor env -> ActivityInboundInterceptor env # |
data ExecuteActivityInput Source #
Constructors
ExecuteActivityInput | |
Fields |
Instances
Show ExecuteActivityInput Source # | |
Defined in Temporal.Workflow.Types Methods showsPrec :: Int -> ExecuteActivityInput -> ShowS # show :: ExecuteActivityInput -> String # showList :: [ExecuteActivityInput] -> ShowS # |
data ActivityOutboundInterceptor env Source #
Constructors
ActivityOutboundInterceptor |
Instances
Monoid (ActivityOutboundInterceptor env) Source # | |
Defined in Temporal.Interceptor Methods mempty :: ActivityOutboundInterceptor env # mappend :: ActivityOutboundInterceptor env -> ActivityOutboundInterceptor env -> ActivityOutboundInterceptor env # mconcat :: [ActivityOutboundInterceptor env] -> ActivityOutboundInterceptor env # | |
Semigroup (ActivityOutboundInterceptor env) Source # | |
Defined in Temporal.Interceptor Methods (<>) :: ActivityOutboundInterceptor env -> ActivityOutboundInterceptor env -> ActivityOutboundInterceptor env # sconcat :: NonEmpty (ActivityOutboundInterceptor env) -> ActivityOutboundInterceptor env # stimes :: Integral b => b -> ActivityOutboundInterceptor env -> ActivityOutboundInterceptor env # |
data WorkflowExitVariant a Source #
data ClientInterceptors Source #
Constructors
ClientInterceptors | |
Fields
|
Instances
Monoid ClientInterceptors Source # | |
Defined in Temporal.Client.Types Methods mempty :: ClientInterceptors # mappend :: ClientInterceptors -> ClientInterceptors -> ClientInterceptors # mconcat :: [ClientInterceptors] -> ClientInterceptors # | |
Semigroup ClientInterceptors Source # | |
Defined in Temporal.Client.Types Methods (<>) :: ClientInterceptors -> ClientInterceptors -> ClientInterceptors # sconcat :: NonEmpty ClientInterceptors -> ClientInterceptors # stimes :: Integral b => b -> ClientInterceptors -> ClientInterceptors # |
data QueryWorkflowInput Source #
data ScheduleClientInterceptors Source #
Constructors
ScheduleClientInterceptors | |
Fields
|
Instances
interceptorConvertChildWorkflowHandle :: ChildWorkflowHandle a -> (a -> IO b) -> ChildWorkflowHandle b Source #
This is only intended for use by interceptors. Normal workflow code should be able to use
the fmap
instance for simple transformations or else provide an appropriate codec.