Skip to content

Commit

Permalink
feat: nacos configstore basically implementation configuration level …
Browse files Browse the repository at this point in the history
…2 function

Complete unit testing has not been conducted yet, there may be potential bugs.
The internal details are not a bit messy yet, and some code needs to be refactored.
Fixed a bug where the dataid configuration could not be successfully uploaded (listened to) if there were special characters that existed before.
  • Loading branch information
cyb0225 committed Jun 14, 2023
1 parent df1fb1a commit 5f69265
Show file tree
Hide file tree
Showing 4 changed files with 242 additions and 47 deletions.
1 change: 1 addition & 0 deletions components/configstores/nacos/change_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type subscriberHolder struct {
type subscriberKey struct {
group string
key string
label string
}

func newSubscriberHolder() *subscriberHolder {
Expand Down
16 changes: 0 additions & 16 deletions components/configstores/nacos/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,6 @@

package nacos

const (
defaultNamespaceId = "" // if this is not set, then nacos will use the default namespaceId.
defaultGroup = "default"
defaultLabel = "default"
defaultLogDir = "/tmp/layotto/nacos/log"
defaultCacheDir = "/tmp/layotto/nacos/cache"
defaultLogLevel = "debug"
defaultTimeout = 10 // second
)

// map keys
const (
namespaceIdKey = "namespace_id"
appNameKey = "app_name"
)

type NacosMetadata struct {
AppName string
NameSpaceId string
Expand Down
39 changes: 39 additions & 0 deletions components/configstores/nacos/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package nacos

import "errors"

var (
// IllegalParam
// This error is usually caused by the logic of the parameters,
// such as filling in parameters with illegal characters
IllegalParam = errors.New("illegal parameter")

// InvalidDataId
// The nacos data_id cannot be divided into key labels using the delimiter set in store instance.
InvalidDataId = errors.New("invalid data_id")

InvalidKey = errors.New("the key contains delimiter which are not allowed")
InvalidLabel = errors.New("the label contains delimiter which are not allowed")
InvalidGroup = errors.New("the group is consistent with the group stored in the set tag")
)

const (
defaultNamespaceId = "" // if this is not set, then nacos will use the default namespaceId.
defaultGroup = "default"
defaultLabel = "default"
defaultLogDir = "/tmp/layotto/nacos/log"
defaultCacheDir = "/tmp/layotto/nacos/cache"
defaultLogLevel = "debug"
defaultTimeout = 10 // second
defaultTagGroup = "sidecar_config_tags"

// Nacos does not allow setting some special characters in the key.
// Only English characters and 4 special characters (".", ":", "-", "_") are allowed, with a maximum of 256 bytes.
defaultDelimiter = ":"
)

// map keys
const (
namespaceIdKey = "namespace_id"
appNameKey = "app_name"
)
Loading

0 comments on commit 5f69265

Please sign in to comment.