Skip to content

Commit

Permalink
fix(config): fix the type of reject request (#1749)
Browse files Browse the repository at this point in the history
  • Loading branch information
justxuewei committed Feb 11, 2022
1 parent 58eef8b commit 2cf7424
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions config/graceful_shutdown_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type ShutdownConfig struct {
InternalSignal bool `default:"true" yaml:"internal-signal" json:"internal.signal,omitempty" property:"internal.signal"`

// true -> new request will be rejected.
RejectRequest bool
RejectRequest atomic.Bool
// active invocation
ConsumerActiveCount atomic.Int32
ProviderActiveCount atomic.Int32
Expand Down Expand Up @@ -138,7 +138,7 @@ func (scb *ShutdownConfigBuilder) SetRejectRequestHandler(rejectRequestHandler s
}

func (scb *ShutdownConfigBuilder) SetRejectRequest(rejectRequest bool) *ShutdownConfigBuilder {
scb.shutdownConfig.RejectRequest = rejectRequest
scb.shutdownConfig.RejectRequest.Store(rejectRequest)
return scb
}

Expand Down
2 changes: 1 addition & 1 deletion config/graceful_shutdown_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

func TestShutdownConfigGetTimeout(t *testing.T) {
config := ShutdownConfig{}
assert.False(t, config.RejectRequest)
assert.False(t, config.RejectRequest.Load())

config = ShutdownConfig{
Timeout: "60s",
Expand Down
2 changes: 1 addition & 1 deletion filter/graceful_shutdown/procider_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestProviderFilterInvoke(t *testing.T) {
assert.NotNil(t, result)
assert.Nil(t, result.Error())

config.GetShutDown().RejectRequest = true
config.GetShutDown().RejectRequest.Store(true)
result = filter.Invoke(context.Background(), protocol.NewBaseInvoker(url), invocation)
assert.NotNil(t, result)
assert.NotNil(t, result.Error().Error(), "Rejected")
Expand Down
2 changes: 1 addition & 1 deletion filter/graceful_shutdown/provider_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (f *providerGracefulShutdownFilter) rejectNewRequest() bool {
if f.shutdownConfig == nil {
return false
}
return f.shutdownConfig.RejectRequest
return f.shutdownConfig.RejectRequest.Load()
}

func (f *providerGracefulShutdownFilter) getRejectHandler() filter.RejectedExecutionHandler {
Expand Down

0 comments on commit 2cf7424

Please sign in to comment.