fix apollo that config update failed while without apollo.WithOriginalConfig option

pull/2872/head
Aaron Ji 1 year ago
parent fcd3b18e83
commit 47fba6c947
No known key found for this signature in database
GPG Key ID: FC6BDB92CD5BEB22
  1. 29
      contrib/config/apollo/watcher.go

@ -25,20 +25,23 @@ type customChangeListener struct {
func (c *customChangeListener) onChange(namespace string, changes map[string]*storage.ConfigChange) []*config.KeyValue {
kv := make([]*config.KeyValue, 0, 2)
if strings.Contains(namespace, ".") && !strings.HasSuffix(namespace, "."+properties) &&
(format(namespace) == yaml || format(namespace) == yml || format(namespace) == json) {
value, err := c.apollo.client.GetConfigCache(namespace).Get("content")
if err != nil {
log.Warnw("apollo get config failed", "err", err)
return nil
if c.apollo.opt.originConfig {
if strings.Contains(namespace, ".") && !strings.HasSuffix(namespace, "."+properties) &&
(format(namespace) == yaml || format(namespace) == yml || format(namespace) == json) {
value, err := c.apollo.client.GetConfigCache(namespace).Get("content")
if err != nil {
log.Errorw("apollo get config failed, be aware that apollo should enable \"apollo.WithOriginalConfig()\" option", "err", err)
return nil
} else {
kv = append(kv, &config.KeyValue{
Key: namespace,
Value: []byte(value.(string)),
Format: format(namespace),
})
return kv
}
}
kv = append(kv, &config.KeyValue{
Key: namespace,
Value: []byte(value.(string)),
Format: format(namespace),
})
return kv
}
next := make(map[string]interface{})

Loading…
Cancel
Save