Skip to content

Commit 6decfc7

Browse files
authored
Expose method to get default worker options (#1311)
1 parent d37290d commit 6decfc7

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

internal/internal_worker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ func newAggregatedWorker(
971971
taskList string,
972972
options WorkerOptions,
973973
) (worker *aggregatedWorker) {
974-
wOptions := augmentWorkerOptions(options)
974+
wOptions := AugmentWorkerOptions(options)
975975
ctx := wOptions.BackgroundActivityContext
976976
if ctx == nil {
977977
ctx = context.Background()
@@ -1192,7 +1192,7 @@ func getReadOnlyChannel(c chan struct{}) <-chan struct{} {
11921192
return c
11931193
}
11941194

1195-
func augmentWorkerOptions(options WorkerOptions) WorkerOptions {
1195+
func AugmentWorkerOptions(options WorkerOptions) WorkerOptions {
11961196
if options.MaxConcurrentActivityExecutionSize == 0 {
11971197
options.MaxConcurrentActivityExecutionSize = defaultMaxConcurrentActivityExecutionSize
11981198
}

internal/internal_worker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ func Test_augmentWorkerOptions(t *testing.T) {
13601360
}
13611361
for _, tt := range tests {
13621362
t.Run(tt.name, func(t *testing.T) {
1363-
assert.Equalf(t, tt.want, augmentWorkerOptions(tt.args.options), "augmentWorkerOptions(%v)", tt.args.options)
1363+
assert.Equalf(t, tt.want, AugmentWorkerOptions(tt.args.options), "AugmentWorkerOptions(%v)", tt.args.options)
13641364
})
13651365
}
13661366
}

internal/internal_workers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func (s *WorkersTestSuite) TestActivityWorkerStop() {
169169
ctx, cancel := context.WithCancel(context.Background())
170170
executionParameters := workerExecutionParameters{
171171
TaskList: "testTaskList",
172-
WorkerOptions: augmentWorkerOptions(
172+
WorkerOptions: AugmentWorkerOptions(
173173
WorkerOptions{
174174
MaxConcurrentActivityTaskPollers: 5,
175175
MaxConcurrentActivityExecutionSize: 2,

internal/internal_workflow_testsuite.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@ func getRetryBackoffFromThriftRetryPolicy(tp *shared.RetryPolicy, attempt int32,
11751175

11761176
func (env *testWorkflowEnvironmentImpl) ExecuteLocalActivity(params executeLocalActivityParams, callback laResultHandler) *localActivityInfo {
11771177
activityID := getStringID(env.nextID())
1178-
wOptions := augmentWorkerOptions(env.workerOptions)
1178+
wOptions := AugmentWorkerOptions(env.workerOptions)
11791179
ae := &activityExecutor{name: getActivityFunctionName(env.registry, params.ActivityFn), fn: params.ActivityFn}
11801180
if at, _ := getValidatedActivityFunction(params.ActivityFn, params.InputArgs, env.registry); at != nil {
11811181
// local activity could be registered, if so use the registered name. This name is only used to find a mock.
@@ -1623,7 +1623,7 @@ func (m *mockWrapper) executeMockWithActualArgs(ctx interface{}, inputArgs []int
16231623
}
16241624

16251625
func (env *testWorkflowEnvironmentImpl) newTestActivityTaskHandler(taskList string, dataConverter DataConverter) ActivityTaskHandler {
1626-
wOptions := augmentWorkerOptions(env.workerOptions)
1626+
wOptions := AugmentWorkerOptions(env.workerOptions)
16271627
wOptions.DataConverter = dataConverter
16281628
params := workerExecutionParameters{
16291629
WorkerOptions: wOptions,

worker/worker.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,9 @@ func SetBinaryChecksum(checksum string) {
356356
func NewAdminJwtAuthorizationProvider(privateKey []byte) AuthorizationProvider {
357357
return internal.NewAdminJwtAuthorizationProvider(privateKey)
358358
}
359+
360+
// AugmentWorkerOptions fill all unset worker Options fields with their default values
361+
// Use as getter for default worker options
362+
func AugmentWorkerOptions(options Options) Options {
363+
return internal.AugmentWorkerOptions(options)
364+
}

0 commit comments

Comments
 (0)