Skip to content

Commit

Permalink
The NotLoadCacheAtStart parameter is added to nacos
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxToby committed Oct 30, 2023
1 parent b225867 commit af9ae85
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions zrpc/registry/nacos/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func (b *builder) Build(url resolver.Target, conn resolver.ClientConn, opts reso
Username: tgt.User,
Password: tgt.Password,
TimeoutMs: uint64(tgt.Timeout),
NotLoadCacheAtStart: tgt.NotLoadCacheAtStart,
UpdateCacheWhenEmpty: tgt.UpdateCacheWhenEmpty,
}

if tgt.CacheDir != "" {
Expand Down
18 changes: 18 additions & 0 deletions zrpc/registry/nacos/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type target struct {
LogLevel string `key:",optional"`
LogDir string `key:",optional"`
CacheDir string `key:",optional"`
NotLoadCacheAtStart bool `key:"notLoadCacheAtStart,optional"`
UpdateCacheWhenEmpty bool `key:"updateCacheWhenEmpty,optional"`
}

// parseURL with parameters
Expand Down Expand Up @@ -57,5 +59,21 @@ func parseURL(rawURL url.URL) (target, error) {
tgt.Addr = rawURL.Host
tgt.Service = strings.TrimLeft(rawURL.Path, "/")

if logLevel, exists := os.LookupEnv("NACOS_LOG_LEVEL"); exists {
tgt.LogLevel = logLevel
}

if logDir, exists := os.LookupEnv("NACOS_LOG_DIR"); exists {
tgt.LogDir = logDir
}

if notLoadCacheAtStart, exists := os.LookupEnv("NACOS_NOT_LOAD_CACHE_AT_START"); exists {
tgt.NotLoadCacheAtStart = notLoadCacheAtStart == "true"
}

if updateCacheWhenEmpty, exists := os.LookupEnv("NACOS_UPDATE_CACHE_WHEN_EMPTY"); exists {
tgt.UpdateCacheWhenEmpty = updateCacheWhenEmpty == "true"
}

return tgt, nil
}

1 comment on commit af9ae85

@MaxToby
Copy link
Collaborator Author

@MaxToby MaxToby commented on af9ae85 Oct 30, 2023

Choose a reason for hiding this comment

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

This commit fixes #277 #169 #198

Please sign in to comment.