-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
959 additions
and
519 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
|
||
"go.temporal.io/sdk/interceptor" | ||
"go.temporal.io/sdk/workflow" | ||
) | ||
|
||
type LoggedWorkflowInboundInterceptor struct { | ||
interceptor.WorkflowInboundInterceptorBase | ||
Next interceptor.WorkflowInboundInterceptor | ||
} | ||
|
||
func NewLoggedWorkflowInboundInterceptor(next interceptor.WorkflowInboundInterceptor) *LoggedWorkflowInboundInterceptor { | ||
return &LoggedWorkflowInboundInterceptor{ | ||
WorkflowInboundInterceptorBase: interceptor.WorkflowInboundInterceptorBase{Next: next}, | ||
Next: next, | ||
} | ||
} | ||
|
||
func (w *LoggedWorkflowInboundInterceptor) ExecuteWorkflow( | ||
ctx workflow.Context, | ||
in *interceptor.ExecuteWorkflowInput, | ||
) (interface{}, error) { | ||
// Workflow starts here | ||
result, err := w.Next.ExecuteWorkflow(ctx, in) | ||
// Workflow ends here | ||
return result, err | ||
} | ||
|
||
type LoggedActivityInboundInterceptor struct { | ||
interceptor.ActivityInboundInterceptorBase | ||
Next interceptor.ActivityInboundInterceptor | ||
} | ||
|
||
func NewLoggedActivityInboundInterceptor(next interceptor.ActivityInboundInterceptor) *LoggedActivityInboundInterceptor { | ||
return &LoggedActivityInboundInterceptor{ | ||
ActivityInboundInterceptorBase: interceptor.ActivityInboundInterceptorBase{Next: next}, | ||
Next: next, | ||
} | ||
} | ||
|
||
func (c *LoggedActivityInboundInterceptor) ExecuteActivity( | ||
ctx context.Context, | ||
in *interceptor.ExecuteActivityInput, | ||
) (interface{}, error) { | ||
// Activity starts here | ||
out, err := c.Next.ExecuteActivity(ctx, in) | ||
// Activity ends here | ||
return out, err | ||
} | ||
|
||
type LoggedWorkerInterceptor struct { | ||
interceptor.WorkerInterceptorBase | ||
} | ||
|
||
func (c LoggedWorkerInterceptor) InterceptActivity( | ||
ctx context.Context, | ||
next interceptor.ActivityInboundInterceptor, | ||
) interceptor.ActivityInboundInterceptor { | ||
return NewLoggedActivityInboundInterceptor(next) | ||
} | ||
|
||
func (c LoggedWorkerInterceptor) InterceptWorkflow( | ||
ctx workflow.Context, | ||
next interceptor.WorkflowInboundInterceptor, | ||
) interceptor.WorkflowInboundInterceptor { | ||
// Workflow intercepted here | ||
intercepted := NewLoggedWorkflowInboundInterceptor(next) | ||
// Workflow intercepting ends here | ||
return intercepted | ||
} | ||
|
||
func NewLoggedWorkerInterceptor() *LoggedWorkerInterceptor { | ||
return &LoggedWorkerInterceptor{ | ||
WorkerInterceptorBase: interceptor.WorkerInterceptorBase{}, | ||
} | ||
} |
Oops, something went wrong.