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

client: rename follower handle var #7577

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 3 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,12 +707,12 @@
return errors.New("[pd] invalid value type for EnableTSOFollowerProxy option, it should be bool")
}
c.option.setEnableTSOFollowerProxy(enable)
case EnableFollowerHandle:
case EnableFollowerHandleRegionRequest:

Check warning on line 710 in client/client.go

View check run for this annotation

Codecov / codecov/patch

client/client.go#L710

Added line #L710 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

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

If we have more and more requests, will the option become bloated in the future?

Copy link
Member Author

Choose a reason for hiding this comment

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

It'll be more, but I don't think it'll be bloated. If there are more options, we can provide a function to turn all options on or off, but we must be able to control them separately

enable, ok := value.(bool)
if !ok {
return errors.New("[pd] invalid value type for EnableFollowerHandle option, it should be bool")
return errors.New("[pd] invalid value type for EnableFollowerHandleRegionRequest option, it should be bool")

Check warning on line 713 in client/client.go

View check run for this annotation

Codecov / codecov/patch

client/client.go#L713

Added line #L713 was not covered by tests
}
c.option.setEnableFollowerHandle(enable)
c.option.setEnableFollowerHandleRegionRequest(enable)

Check warning on line 715 in client/client.go

View check run for this annotation

Codecov / codecov/patch

client/client.go#L715

Added line #L715 was not covered by tests
default:
return errors.New("[pd] unsupported client option")
}
Expand Down
20 changes: 10 additions & 10 deletions client/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const (
// EnableTSOFollowerProxy is the TSO Follower Proxy option.
// It is stored as bool.
EnableTSOFollowerProxy
// EnableFollowerHandle is the follower handle option.
EnableFollowerHandle
// EnableFollowerHandleRegionRequest is the follower handle option for region request .
EnableFollowerHandleRegionRequest

dynamicOptionCount
)
Expand Down Expand Up @@ -75,7 +75,7 @@ func newOption() *option {

co.dynamicOptions[MaxTSOBatchWaitInterval].Store(defaultMaxTSOBatchWaitInterval)
co.dynamicOptions[EnableTSOFollowerProxy].Store(defaultEnableTSOFollowerProxy)
co.dynamicOptions[EnableFollowerHandle].Store(defaultEnableFollowerHandle)
co.dynamicOptions[EnableFollowerHandleRegionRequest].Store(defaultEnableFollowerHandle)
return co
}

Expand All @@ -92,17 +92,17 @@ func (o *option) setMaxTSOBatchWaitInterval(interval time.Duration) error {
return nil
}

// setEnableFollowerHandle set the Follower Handle option.
func (o *option) setEnableFollowerHandle(enable bool) {
old := o.getEnableFollowerHandle()
// setEnableFollowerHandleRegionRequest set the Follower Handle option.
func (o *option) setEnableFollowerHandleRegionRequest(enable bool) {
old := o.isEnableFollowerHandleRegionRequest()
if enable != old {
o.dynamicOptions[EnableFollowerHandle].Store(enable)
o.dynamicOptions[EnableFollowerHandleRegionRequest].Store(enable)
}
}

// getMaxTSOBatchWaitInterval gets the Follower Handle enable option.
func (o *option) getEnableFollowerHandle() bool {
return o.dynamicOptions[EnableFollowerHandle].Load().(bool)
// isEnableFollowerHandleRegionRequest gets the Follower Handle enable option.
func (o *option) isEnableFollowerHandleRegionRequest() bool {
return o.dynamicOptions[EnableFollowerHandleRegionRequest].Load().(bool)
}

// getMaxTSOBatchWaitInterval gets the max TSO batch wait interval option.
Expand Down
10 changes: 5 additions & 5 deletions client/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestDynamicOptionChange(t *testing.T) {
// Check the default value setting.
re.Equal(defaultMaxTSOBatchWaitInterval, o.getMaxTSOBatchWaitInterval())
re.Equal(defaultEnableTSOFollowerProxy, o.getEnableTSOFollowerProxy())
re.Equal(defaultEnableFollowerHandle, o.getEnableFollowerHandle())
re.Equal(defaultEnableFollowerHandle, o.isEnableFollowerHandleRegionRequest())

// Check the invalid value setting.
re.Error(o.setMaxTSOBatchWaitInterval(time.Second))
Expand Down Expand Up @@ -58,9 +58,9 @@ func TestDynamicOptionChange(t *testing.T) {
o.setEnableTSOFollowerProxy(expectBool)

expectBool = true
o.setEnableFollowerHandle(expectBool)
re.Equal(expectBool, o.getEnableFollowerHandle())
o.setEnableFollowerHandleRegionRequest(expectBool)
re.Equal(expectBool, o.isEnableFollowerHandleRegionRequest())
expectBool = false
o.setEnableFollowerHandle(expectBool)
re.Equal(expectBool, o.getEnableFollowerHandle())
o.setEnableFollowerHandleRegionRequest(expectBool)
re.Equal(expectBool, o.isEnableFollowerHandleRegionRequest())
}
Loading