Skip to content

Commit

Permalink
alter client config by deffer delay check
Browse files Browse the repository at this point in the history
  • Loading branch information
xuxiaoliang authored and xuxiaoliang committed Jun 14, 2020
1 parent e00853c commit 69b4eb3
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions protocol/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,22 @@ var (

func init() {
// load clientconfig from consumer_config
// default use grpc
defaultClientConfig := GetDefaultClientConfig()
clientConf = &defaultClientConfig
consumerConfig := config.GetConsumerConfig()

clientConfig := GetClientConfig()
clientConf = &clientConfig

// check client config and decide whether to use the default config
defer func() {
if clientConf == nil || len(clientConf.ContentSubType) == 0 {
defaultClientConfig := GetDefaultClientConfig()
clientConf = &defaultClientConfig
}
if err := clientConf.Validate(); err != nil {
panic(err)
}
}()

if consumerConfig.ApplicationConfig == nil {
return
}
Expand All @@ -69,12 +80,6 @@ func init() {
}
}

if clientConf == nil || len(clientConf.ContentSubType) == 0 {
clientConf = &defaultClientConfig
}
if err := clientConf.Validate(); err != nil {
panic(err)
}
}

// Client return grpc connection and warp service stub
Expand Down

0 comments on commit 69b4eb3

Please sign in to comment.