Skip to content

Commit 4c1c0de

Browse files
authored
Simplify worker options configuration value propagation (#1179)
* rename workerExecutionParameters fields to match WorkerOptions * use embedding of WorkerOptions to make assignment easier * fix test * rename workflowInterceptors to workflowInterceptorFactories
1 parent e66e2d4 commit 4c1c0de

13 files changed

+267
-285
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package autoscaler

internal/interceptors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ type WorkflowInterceptor interface {
7272

7373
var _ WorkflowInterceptor = (*WorkflowInterceptorBase)(nil)
7474

75-
// WorkflowInterceptorBase is a helper type that can simplify creation of WorkflowInterceptors
75+
// WorkflowInterceptorBase is a helper type that can simplify creation of WorkflowInterceptorChainFactories
7676
type WorkflowInterceptorBase struct {
7777
Next WorkflowInterceptor
7878
}

internal/internal_event_handlers.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ type (
112112
isReplay bool // flag to indicate if workflow is in replay mode
113113
enableLoggingInReplay bool // flag to indicate if workflow should enable logging in replay mode
114114

115-
metricsScope tally.Scope
116-
registry *registry
117-
dataConverter DataConverter
118-
contextPropagators []ContextPropagator
119-
tracer opentracing.Tracer
120-
workflowInterceptors []WorkflowInterceptorFactory
115+
metricsScope tally.Scope
116+
registry *registry
117+
dataConverter DataConverter
118+
contextPropagators []ContextPropagator
119+
tracer opentracing.Tracer
120+
workflowInterceptorFactories []WorkflowInterceptorFactory
121121
}
122122

123123
localActivityTask struct {
@@ -201,24 +201,24 @@ func newWorkflowExecutionEventHandler(
201201
dataConverter DataConverter,
202202
contextPropagators []ContextPropagator,
203203
tracer opentracing.Tracer,
204-
workflowInterceptors []WorkflowInterceptorFactory,
204+
workflowInterceptorFactories []WorkflowInterceptorFactory,
205205
) workflowExecutionEventHandler {
206206
context := &workflowEnvironmentImpl{
207-
workflowInfo: workflowInfo,
208-
decisionsHelper: newDecisionsHelper(),
209-
sideEffectResult: make(map[int32][]byte),
210-
mutableSideEffect: make(map[string][]byte),
211-
changeVersions: make(map[string]Version),
212-
pendingLaTasks: make(map[string]*localActivityTask),
213-
unstartedLaTasks: make(map[string]struct{}),
214-
openSessions: make(map[string]*SessionInfo),
215-
completeHandler: completeHandler,
216-
enableLoggingInReplay: enableLoggingInReplay,
217-
registry: registry,
218-
dataConverter: dataConverter,
219-
contextPropagators: contextPropagators,
220-
tracer: tracer,
221-
workflowInterceptors: workflowInterceptors,
207+
workflowInfo: workflowInfo,
208+
decisionsHelper: newDecisionsHelper(),
209+
sideEffectResult: make(map[int32][]byte),
210+
mutableSideEffect: make(map[string][]byte),
211+
changeVersions: make(map[string]Version),
212+
pendingLaTasks: make(map[string]*localActivityTask),
213+
unstartedLaTasks: make(map[string]struct{}),
214+
openSessions: make(map[string]*SessionInfo),
215+
completeHandler: completeHandler,
216+
enableLoggingInReplay: enableLoggingInReplay,
217+
registry: registry,
218+
dataConverter: dataConverter,
219+
contextPropagators: contextPropagators,
220+
tracer: tracer,
221+
workflowInterceptorFactories: workflowInterceptorFactories,
222222
}
223223
context.logger = logger.With(
224224
zapcore.Field{Key: tagWorkflowType, Type: zapcore.StringType, String: workflowInfo.WorkflowType.Name},
@@ -771,7 +771,7 @@ func (wc *workflowEnvironmentImpl) GetRegistry() *registry {
771771
}
772772

773773
func (wc *workflowEnvironmentImpl) GetWorkflowInterceptors() []WorkflowInterceptorFactory {
774-
return wc.workflowInterceptors
774+
return wc.workflowInterceptorFactories
775775
}
776776

777777
func (weh *workflowExecutionEventHandlerImpl) ProcessEvent(

internal/internal_task_handlers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ type (
125125
dataConverter DataConverter
126126
contextPropagators []ContextPropagator
127127
tracer opentracing.Tracer
128-
workflowInterceptors []WorkflowInterceptorFactory
128+
workflowInterceptorFactories []WorkflowInterceptorFactory
129129
}
130130

131131
activityProvider func(name string) activity
@@ -396,7 +396,7 @@ func newWorkflowTaskHandler(
396396
dataConverter: params.DataConverter,
397397
contextPropagators: params.ContextPropagators,
398398
tracer: params.Tracer,
399-
workflowInterceptors: params.WorkflowInterceptors,
399+
workflowInterceptorFactories: params.WorkflowInterceptorChainFactories,
400400
}
401401
}
402402

@@ -591,7 +591,7 @@ func (w *workflowExecutionContextImpl) createEventHandler() {
591591
w.wth.dataConverter,
592592
w.wth.contextPropagators,
593593
w.wth.tracer,
594-
w.wth.workflowInterceptors,
594+
w.wth.workflowInterceptorFactories,
595595
)
596596
w.eventHandler.Store(eventHandler)
597597
}

0 commit comments

Comments
 (0)