Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scanner start dep #3513

Merged
merged 2 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions service/worker/scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type (
scannerContext struct {
cfg *Config
logger log.Logger
sdkSystemClient sdkclient.Client
sdkClientFactory sdk.ClientFactory
metricsClient metrics.Client
executionManager persistence.ExecutionManager
taskManager persistence.TaskManager
Expand All @@ -109,7 +109,7 @@ type (
func New(
logger log.Logger,
cfg *Config,
sdkSystemClient sdkclient.Client,
sdkClientFactory sdk.ClientFactory,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth to add comment why client itself can't be injected here.

metricsClient metrics.Client,
executionManager persistence.ExecutionManager,
taskManager persistence.TaskManager,
Expand All @@ -120,7 +120,7 @@ func New(
return &Scanner{
context: scannerContext{
cfg: cfg,
sdkSystemClient: sdkSystemClient,
sdkClientFactory: sdkClientFactory,
logger: logger,
metricsClient: metricsClient,
executionManager: executionManager,
Expand Down Expand Up @@ -166,7 +166,7 @@ func (s *Scanner) Start() error {
}

for _, tl := range workerTaskQueueNames {
work := s.context.workerFactory.New(s.context.sdkSystemClient, tl, workerOpts)
work := s.context.workerFactory.New(s.context.sdkClientFactory.GetSystemClient(), tl, workerOpts)

work.RegisterWorkflowWithOptions(TaskQueueScannerWorkflow, workflow.RegisterOptions{Name: tqScannerWFTypeName})
work.RegisterWorkflowWithOptions(HistoryScannerWorkflow, workflow.RegisterOptions{Name: historyScannerWFTypeName})
Expand Down Expand Up @@ -198,7 +198,7 @@ func (s *Scanner) startWorkflowWithRetry(
WithMaximumInterval(time.Minute).
WithExpirationInterval(backoff.NoInterval)
err := backoff.ThrottleRetry(func() error {
return s.startWorkflow(s.context.sdkSystemClient, options, workflowType, workflowArgs...)
return s.startWorkflow(s.context.sdkClientFactory.GetSystemClient(), options, workflowType, workflowArgs...)
}, policy, func(err error) bool {
return true
})
Expand Down
4 changes: 3 additions & 1 deletion service/worker/scanner/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func (s *scannerTestSuite) TestScannerEnabled() {
s.Run(c.Name, func() {
ctrl := gomock.NewController(s.T())
mockWorkerFactory := sdk.NewMockWorkerFactory(ctrl)
mockSdkClientFactory := sdk.NewMockClientFactory(ctrl)
mockSdkClient := mocksdk.NewMockClient(ctrl)
mockNamespaceRegistry := namespace.NewMockRegistry(ctrl)
scanner := New(
Expand Down Expand Up @@ -189,7 +190,7 @@ func (s *scannerTestSuite) TestScannerEnabled() {
},
},
},
mockSdkClient,
mockSdkClientFactory,
metrics.NoopClient,
p.NewMockExecutionManager(ctrl),
p.NewMockTaskManager(ctrl),
Expand All @@ -203,6 +204,7 @@ func (s *scannerTestSuite) TestScannerEnabled() {
worker.EXPECT().RegisterWorkflowWithOptions(gomock.Any(), gomock.Any()).AnyTimes()
worker.EXPECT().Start()
mockWorkerFactory.EXPECT().New(gomock.Any(), sc.TaskQueueName, gomock.Any()).Return(worker)
mockSdkClientFactory.EXPECT().GetSystemClient().Return(mockSdkClient).AnyTimes()
mockSdkClient.EXPECT().ExecuteWorkflow(gomock.Any(), gomock.Any(), sc.WFTypeName, gomock.Any())
}
err := scanner.Start()
Expand Down
2 changes: 1 addition & 1 deletion service/worker/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ func (s *Service) initScanner() {
s.scanner = scanner.New(
s.logger,
s.config.ScannerCfg,
s.sdkClientFactory.GetSystemClient(),
s.sdkClientFactory,
s.metricsClient,
s.executionManager,
s.taskManager,
Expand Down