@@ -15,15 +15,15 @@ import (
15
15
"github.com/cschleiden/go-workflows/internal/log"
16
16
"github.com/cschleiden/go-workflows/internal/metrickeys"
17
17
im "github.com/cschleiden/go-workflows/internal/metrics"
18
- "github.com/cschleiden/go-workflows/internal/workflow"
19
- "github.com/cschleiden/go-workflows/internal/workflow/cache"
20
18
"github.com/cschleiden/go-workflows/registry"
19
+ "github.com/cschleiden/go-workflows/workflow/executor"
20
+ "github.com/cschleiden/go-workflows/workflow/executor/cache"
21
21
)
22
22
23
23
type WorkflowWorkerOptions struct {
24
24
WorkerOptions
25
25
26
- WorkflowExecutorCache workflow. ExecutorCache
26
+ WorkflowExecutorCache executor. Cache
27
27
WorkflowExecutorCacheSize int
28
28
WorkflowExecutorCacheTTL time.Duration
29
29
}
@@ -32,7 +32,7 @@ func NewWorkflowWorker(
32
32
b backend.Backend ,
33
33
registry * registry.Registry ,
34
34
options WorkflowWorkerOptions ,
35
- ) * Worker [backend.WorkflowTask , workflow .ExecutionResult ] {
35
+ ) * Worker [backend.WorkflowTask , executor .ExecutionResult ] {
36
36
if options .WorkflowExecutorCache == nil {
37
37
options .WorkflowExecutorCache = cache .NewWorkflowExecutorLRUCache (b .Metrics (), options .WorkflowExecutorCacheSize , options .WorkflowExecutorCacheTTL )
38
38
}
@@ -44,13 +44,13 @@ func NewWorkflowWorker(
44
44
logger : b .Logger (),
45
45
}
46
46
47
- return NewWorker [backend.WorkflowTask , workflow .ExecutionResult ](b , tw , & options .WorkerOptions )
47
+ return NewWorker [backend.WorkflowTask , executor .ExecutionResult ](b , tw , & options .WorkerOptions )
48
48
}
49
49
50
50
type WorkflowTaskWorker struct {
51
51
backend backend.Backend
52
52
registry * registry.Registry
53
- cache workflow. ExecutorCache
53
+ cache executor. Cache
54
54
logger * slog.Logger
55
55
}
56
56
@@ -63,7 +63,7 @@ func (wtw *WorkflowTaskWorker) Start(ctx context.Context) error {
63
63
}
64
64
65
65
// Complete implements TaskWorker.
66
- func (wtw * WorkflowTaskWorker ) Complete (ctx context.Context , result * workflow .ExecutionResult , t * backend.WorkflowTask ) error {
66
+ func (wtw * WorkflowTaskWorker ) Complete (ctx context.Context , result * executor .ExecutionResult , t * backend.WorkflowTask ) error {
67
67
logger := wtw .logger .With (
68
68
slog .String (log .TaskIDKey , t .ID ),
69
69
slog .String (log .InstanceIDKey , t .WorkflowInstance .InstanceID ),
@@ -99,7 +99,7 @@ func (wtw *WorkflowTaskWorker) Complete(ctx context.Context, result *workflow.Ex
99
99
return nil
100
100
}
101
101
102
- func (wtw * WorkflowTaskWorker ) Execute (ctx context.Context , t * backend.WorkflowTask ) (* workflow .ExecutionResult , error ) {
102
+ func (wtw * WorkflowTaskWorker ) Execute (ctx context.Context , t * backend.WorkflowTask ) (* executor .ExecutionResult , error ) {
103
103
// Record how long this task was in the queue
104
104
firstEvent := t .NewEvents [0 ]
105
105
var scheduledAt time.Time
@@ -154,15 +154,15 @@ func (wtw *WorkflowTaskWorker) Get(ctx context.Context) (*backend.WorkflowTask,
154
154
return t , nil
155
155
}
156
156
157
- func (wtw * WorkflowTaskWorker ) getExecutor (ctx context.Context , t * backend.WorkflowTask ) (workflow .WorkflowExecutor , error ) {
157
+ func (wtw * WorkflowTaskWorker ) getExecutor (ctx context.Context , t * backend.WorkflowTask ) (executor .WorkflowExecutor , error ) {
158
158
// Try to get a cached executor
159
- executor , ok , err := wtw .cache .Get (ctx , t .WorkflowInstance )
159
+ e , ok , err := wtw .cache .Get (ctx , t .WorkflowInstance )
160
160
if err != nil {
161
161
wtw .logger .ErrorContext (ctx , "could not get cached workflow task executor" , "error" , err )
162
162
}
163
163
164
164
if ! ok {
165
- executor , err = workflow .NewExecutor (
165
+ e , err = executor .NewExecutor (
166
166
wtw .logger .With (
167
167
slog .String (log .InstanceIDKey , t .WorkflowInstance .InstanceID ),
168
168
slog .String (log .ExecutionIDKey , t .WorkflowInstance .ExecutionID ),
@@ -182,9 +182,9 @@ func (wtw *WorkflowTaskWorker) getExecutor(ctx context.Context, t *backend.Workf
182
182
}
183
183
184
184
// Cache executor instance for future continuation tasks, or refresh last access time
185
- if err := wtw .cache .Store (ctx , t .WorkflowInstance , executor ); err != nil {
185
+ if err := wtw .cache .Store (ctx , t .WorkflowInstance , e ); err != nil {
186
186
wtw .logger .ErrorContext (ctx , "error while caching workflow task executor:" , "error" , err )
187
187
}
188
188
189
- return executor , nil
189
+ return e , nil
190
190
}
0 commit comments