marsevilspirit commented on code in PR #2906:
URL: https://github.com/apache/dubbo-go/pull/2906#discussion_r2118990056


##########
graceful_shutdown/options.go:
##########
@@ -65,11 +65,11 @@ func WithConsumerUpdateWaitTime(duration time.Duration) 
Option {
 }
 
 // todo(DMwangnima): add more specified configuration API
-//func WithRejectRequestHandler(handler string) Option {
-//     return func(opts *Options) {
-//             opts.Shutdown.RejectRequestHandler = handler
-//     }
-//}
+func WithRejectRequestHandler(handler string) Option {

Review Comment:
   Why expose this API?



##########
filter/graceful_shutdown/compat.go:
##########


Review Comment:
   Why move to filter dir?
   I think graceful_shutdown/compat.go is a very beautful place.



##########
filter/graceful_shutdown/provider_filter.go:
##########
@@ -90,11 +91,16 @@ func (f *providerGracefulShutdownFilter) OnResponse(ctx 
context.Context, result
 func (f *providerGracefulShutdownFilter) Set(name string, conf any) {
        switch name {
        case constant.GracefulShutdownFilterShutdownConfig:
-               if shutdownConfig, ok := conf.(*config.ShutdownConfig); ok {
+               if shutdownConfig, ok := conf.(*global.ShutdownConfig); ok {
                        f.shutdownConfig = shutdownConfig
                        return
                }
-               logger.Warnf("the type of config for {%s} should be 
*config.ShutdownConfig", constant.GracefulShutdownFilterShutdownConfig)
+               // only for compatibility with old config, able to directly 
remove after config is deleted

Review Comment:
   same as above.



##########
config/graceful_shutdown.go:
##########
@@ -55,19 +55,19 @@ const defaultShutDownTime = time.Second * 60
 
 func gracefulShutdownInit() {
        // retrieve ShutdownConfig for gracefulShutdownFilter
-       cGracefulShutdownFilter, existcGracefulShutdownFilter := 
extension.GetFilter(constant.GracefulShutdownConsumerFilterKey)
+       consumerGracefulShutdownFilter, existcGracefulShutdownFilter := 
extension.GetFilter(constant.GracefulShutdownConsumerFilterKey)
        if !existcGracefulShutdownFilter {
                return
        }
-       sGracefulShutdownFilter, existsGracefulShutdownFilter := 
extension.GetFilter(constant.GracefulShutdownProviderFilterKey)
+       providerGracefulShutdownFilter, existsGracefulShutdownFilter := 
extension.GetFilter(constant.GracefulShutdownProviderFilterKey)

Review Comment:
   rename `existcGracefulShutdownFilter` and `existsGracefulShutdownFilter` to 
exist.
   you can code like:
   ```go
   var exist bool
   ...
   ```
   
   rename consumerGracefulShutdownFilter to gracefulShutdownConsumerFilter
   rename providerGracefulShutdownFilter to gracefulShutdownProviderFilter



##########
filter/graceful_shutdown/consumer_filter.go:
##########
@@ -76,11 +77,16 @@ func (f *consumerGracefulShutdownFilter) OnResponse(ctx 
context.Context, result
 func (f *consumerGracefulShutdownFilter) Set(name string, conf any) {
        switch name {
        case constant.GracefulShutdownFilterShutdownConfig:
-               if shutdownConfig, ok := conf.(*config.ShutdownConfig); ok {
+               if shutdownConfig, ok := conf.(*global.ShutdownConfig); ok {

Review Comment:
   You need to make the priority of global the highest.
   currently, config has a higher priority than global.



##########
graceful_shutdown/shutdown.go:
##########
@@ -49,8 +50,8 @@ const (
 )
 
 var (
-       initOnce       sync.Once
-       compatShutdown *config.ShutdownConfig
+       initOnce sync.Once
+       shutdown *global.ShutdownConfig

Review Comment:
   Just continue using config here, the global variables will need to be 
deleted later, changing it to global makes no sense.



##########
graceful_shutdown/shutdown.go:
##########
@@ -63,7 +64,7 @@ func Init(opts ...Option) {
                for _, opt := range opts {
                        opt(newOpts)
                }
-               compatShutdown = compatShutdownConfig(newOpts.Shutdown)

Review Comment:
   After deleting the config package, we can directly use newOpts.Shutdown.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to