Skip to content

Commit

Permalink
Expose method to get default worker options (#1311)
Browse files Browse the repository at this point in the history
  • Loading branch information
ketsiambaku authored Feb 21, 2024
1 parent d37290d commit 6decfc7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/internal_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ func newAggregatedWorker(
taskList string,
options WorkerOptions,
) (worker *aggregatedWorker) {
wOptions := augmentWorkerOptions(options)
wOptions := AugmentWorkerOptions(options)
ctx := wOptions.BackgroundActivityContext
if ctx == nil {
ctx = context.Background()
Expand Down Expand Up @@ -1192,7 +1192,7 @@ func getReadOnlyChannel(c chan struct{}) <-chan struct{} {
return c
}

func augmentWorkerOptions(options WorkerOptions) WorkerOptions {
func AugmentWorkerOptions(options WorkerOptions) WorkerOptions {
if options.MaxConcurrentActivityExecutionSize == 0 {
options.MaxConcurrentActivityExecutionSize = defaultMaxConcurrentActivityExecutionSize
}
Expand Down
2 changes: 1 addition & 1 deletion internal/internal_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,7 @@ func Test_augmentWorkerOptions(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equalf(t, tt.want, augmentWorkerOptions(tt.args.options), "augmentWorkerOptions(%v)", tt.args.options)
assert.Equalf(t, tt.want, AugmentWorkerOptions(tt.args.options), "AugmentWorkerOptions(%v)", tt.args.options)
})
}
}
2 changes: 1 addition & 1 deletion internal/internal_workers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (s *WorkersTestSuite) TestActivityWorkerStop() {
ctx, cancel := context.WithCancel(context.Background())
executionParameters := workerExecutionParameters{
TaskList: "testTaskList",
WorkerOptions: augmentWorkerOptions(
WorkerOptions: AugmentWorkerOptions(
WorkerOptions{
MaxConcurrentActivityTaskPollers: 5,
MaxConcurrentActivityExecutionSize: 2,
Expand Down
4 changes: 2 additions & 2 deletions internal/internal_workflow_testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ func getRetryBackoffFromThriftRetryPolicy(tp *shared.RetryPolicy, attempt int32,

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

func (env *testWorkflowEnvironmentImpl) newTestActivityTaskHandler(taskList string, dataConverter DataConverter) ActivityTaskHandler {
wOptions := augmentWorkerOptions(env.workerOptions)
wOptions := AugmentWorkerOptions(env.workerOptions)
wOptions.DataConverter = dataConverter
params := workerExecutionParameters{
WorkerOptions: wOptions,
Expand Down
6 changes: 6 additions & 0 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,9 @@ func SetBinaryChecksum(checksum string) {
func NewAdminJwtAuthorizationProvider(privateKey []byte) AuthorizationProvider {
return internal.NewAdminJwtAuthorizationProvider(privateKey)
}

// AugmentWorkerOptions fill all unset worker Options fields with their default values
// Use as getter for default worker options
func AugmentWorkerOptions(options Options) Options {
return internal.AugmentWorkerOptions(options)
}

0 comments on commit 6decfc7

Please sign in to comment.