Skip to content

Commit d740aad

Browse files
lvan100lianghuan
authored andcommitted
refactor(conf): upgrade barky
1 parent b300b75 commit d740aad

File tree

8 files changed

+8
-306
lines changed

8 files changed

+8
-306
lines changed

conf/conf.go

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ import (
133133
"github.com/go-spring/spring-core/conf/reader/prop"
134134
"github.com/go-spring/spring-core/conf/reader/toml"
135135
"github.com/go-spring/spring-core/conf/reader/yaml"
136-
"github.com/go-spring/spring-core/util"
137136
"github.com/spf13/cast"
138137
)
139138

@@ -248,15 +247,15 @@ func Load(file string) (*MutableProperties, error) {
248247
return nil, err
249248
}
250249
p := New()
251-
_ = p.merge(util.FlattenMap(m), file)
250+
_ = p.merge(barky.FlattenMap(m), file)
252251
return p, nil
253252
}
254253

255254
// Map creates *MutableProperties from map.
256255
func Map(m map[string]any) *MutableProperties {
257256
p := New()
258257
_, file, _, _ := runtime.Caller(1)
259-
_ = p.merge(util.FlattenMap(m), file)
258+
_ = p.merge(barky.FlattenMap(m), file)
260259
return p
261260
}
262261

@@ -271,29 +270,6 @@ func (p *MutableProperties) merge(m map[string]string, file string) error {
271270
return nil
272271
}
273272

274-
// Data returns key-value pairs of the properties.
275-
func (p *MutableProperties) Data() map[string]string {
276-
m := make(map[string]string)
277-
for k, v := range p.RawData() {
278-
m[k] = v.Value
279-
}
280-
return m
281-
}
282-
283-
// Keys returns keys of the properties.
284-
func (p *MutableProperties) Keys() []string {
285-
return util.OrderedMapKeys(p.RawData())
286-
}
287-
288-
// Get returns key's value, using Def to return a default value.
289-
func (p *MutableProperties) Get(key string, def ...string) string {
290-
v, ok := p.RawData()[key]
291-
if !ok && len(def) > 0 {
292-
return def[0]
293-
}
294-
return v.Value
295-
}
296-
297273
// Resolve resolves string value that contains references to other
298274
// properties, the references are defined by ${key:=def}.
299275
func (p *MutableProperties) Resolve(s string) (string, error) {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24
44

55
require (
66
github.com/expr-lang/expr v1.17.5
7-
github.com/go-spring/barky v1.0.2
7+
github.com/go-spring/barky v1.0.3
88
github.com/go-spring/gs-assert v1.0.2
99
github.com/go-spring/gs-mock v0.0.4
1010
github.com/go-spring/log v0.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ github.com/expr-lang/expr v1.17.5 h1:i1WrMvcdLF249nSNlpQZN1S6NXuW9WaOfF5tPi3aw3k
22
github.com/expr-lang/expr v1.17.5/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
33
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
44
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
5-
github.com/go-spring/barky v1.0.2 h1:HZuoFKrZMDg4ILwxwNfrAToU2zY1I3y05GfNiO5RXVc=
6-
github.com/go-spring/barky v1.0.2/go.mod h1:O6b8NWXMhKNA7D0zYbKN/62OcZGb/aSOaPihkKPU23k=
5+
github.com/go-spring/barky v1.0.3 h1:24U2IX47es7JfuAx7WkkOqBEV0bOy49/ZW4GCkVvD7Q=
6+
github.com/go-spring/barky v1.0.3/go.mod h1:IlEMJj9d//EQs2oin0tuGKGACslZe73khbHcDPzF9KE=
77
github.com/go-spring/gs-assert v1.0.2 h1:9vDppl7ZwMvQE4c83ac7GzN0VxZC5BrQue7dND7NclQ=
88
github.com/go-spring/gs-assert v1.0.2/go.mod h1:FfibkqWz4HUBpbig1cKMlzW8Ha7RywTB93f1Q/NuF9I=
99
github.com/go-spring/gs-mock v0.0.4 h1:f34YN+ntXflfn13aLa3ZVCB78IG7wWZGK4y5tB+OGpI=

gs/internal/gs_dync/dync.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ import (
6767
"sync"
6868
"sync/atomic"
6969

70+
"github.com/go-spring/barky"
7071
"github.com/go-spring/spring-core/conf"
71-
"github.com/go-spring/spring-core/util"
7272
)
7373

7474
// refreshable represents an object that can be dynamically refreshed.
@@ -209,7 +209,7 @@ func (p *Properties) Refresh(prop conf.Properties) (err error) {
209209
changes[k] = struct{}{}
210210
}
211211

212-
keys := util.OrderedMapKeys(changes)
212+
keys := barky.OrderedMapKeys(changes)
213213
return p.refreshKeys(keys)
214214
}
215215

@@ -233,7 +233,7 @@ func (p *Properties) refreshKeys(keys []string) (err error) {
233233
// Sort and collect objects that need updating.
234234
updateObjects := make([]*refreshObject, 0, len(updateIndexes))
235235
{
236-
ints := util.OrderedMapKeys(updateIndexes)
236+
ints := barky.OrderedMapKeys(updateIndexes)
237237
for _, k := range ints {
238238
updateObjects = append(updateObjects, updateIndexes[k])
239239
}

util/flat.go

Lines changed: 0 additions & 74 deletions
This file was deleted.

util/flat_test.go

Lines changed: 0 additions & 88 deletions
This file was deleted.

util/map.go

Lines changed: 0 additions & 38 deletions
This file was deleted.

util/map_test.go

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)