/
temporal_interceptor_plugin.go
58 lines (47 loc) · 1.16 KB
/
temporal_interceptor_plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package tests
import (
"context"
"os"
"go.temporal.io/sdk/interceptor"
"go.temporal.io/sdk/workflow"
)
type TemporalInterceptorPlugin struct {
config Configurer
}
func (pt *TemporalInterceptorPlugin) Init(cfg Configurer) error {
pt.config = cfg
return nil
}
func (pt *TemporalInterceptorPlugin) Serve() chan error {
errCh := make(chan error, 1)
return errCh
}
func (pt *TemporalInterceptorPlugin) Stop(context.Context) error {
return nil
}
func (pt *TemporalInterceptorPlugin) Name() string {
return "temporal_test.incterceptor_plugin"
}
func (pt *TemporalInterceptorPlugin) WorkerInterceptor() interceptor.WorkerInterceptor {
return &workerInterceptor{}
}
type workerInterceptor struct {
interceptor.WorkerInterceptorBase
}
func (w *workerInterceptor) InterceptActivity(
ctx context.Context,
next interceptor.ActivityInboundInterceptor,
) interceptor.ActivityInboundInterceptor {
f, err := os.Create("./interceptor_test")
if err != nil {
panic(err)
}
f.Close()
return next
}
func (w *workerInterceptor) InterceptWorkflow(
ctx workflow.Context,
next interceptor.WorkflowInboundInterceptor,
) interceptor.WorkflowInboundInterceptor {
return next
}