Skip to content

Commit a12bcc6

Browse files
author
tietang
committed
add 配置备份功能
1 parent 320b478 commit a12bcc6

File tree

6 files changed

+449
-382
lines changed

6 files changed

+449
-382
lines changed

example/ccs.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package main
22

33
import (
4-
"time"
54
"fmt"
65
"github.com/tietang/props/kvs"
7-
"github.com/tietang/props/zk"
86
)
97

108
func main() {
@@ -28,11 +26,12 @@ func main() {
2826
//指定名称和文件名
2927
pcs2 := kvs.NewPropertiesConfigSourceByFile("config", "config.properties")
3028

31-
urls := []string{"172.16.1.248:2181"}
32-
contexts := []string{"/configs/apps", "/configs/users"}
33-
zccs := zk.NewZookeeperCompositeConfigSource(contexts, urls, time.Second*3)
34-
configSources := []kvs.ConfigSource{pcs1, pcs2, zccs, }
29+
//urls := []string{"172.16.1.248:2181"}
30+
//contexts := []string{"/configs/apps", "/configs/users"}
31+
//zccs := zk.NewZookeeperCompositeConfigSource(contexts, urls, time.Second*3)
32+
configSources := []kvs.ConfigSource{pcs1, pcs2}
3533
ccs := kvs.NewDefaultCompositeConfigSource(configSources...)
34+
ccs.SaveToDisk()
3635

3736
//
3837

@@ -53,4 +52,5 @@ func main() {
5352
fmt.Println(floatValue)
5453
floatDefaultValue := ccs.GetFloat64Default("prefix.key4", 1.2)
5554
fmt.Println(floatDefaultValue)
55+
5656
}

example/config.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
go.app.key1=value1
2+
go.app.key2=value2

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ require (
5555
github.com/pascaldekloe/goe v0.1.0 // indirect
5656
github.com/pkg/errors v0.8.1 // indirect
5757
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 // indirect
58+
github.com/prometheus/common v0.2.0
5859
github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec
5960
github.com/sirupsen/logrus v1.2.0
6061
github.com/smartystreets/assertions v0.0.0-20180301161246-7678a5452ebe // indirect

go.sum

+3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX
66
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
77
github.com/aclements/go-gg v0.0.0-20170118225347-6dbb4e4fefb0/go.mod h1:55qNq4vcpkIuHowELi5C8e+1yUHtoLoOUR9QU5j7Tes=
88
github.com/aclements/go-moremath v0.0.0-20161014184102-0ff62e0875ff/go.mod h1:idZL3yvz4kzx1dsBOAC+oYv6L92P1oFEhUXUB1A/lwQ=
9+
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
910
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
11+
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
1012
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
1113
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
1214
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
@@ -240,6 +242,7 @@ go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
240242
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
241243
go.opencensus.io v0.19.2/go.mod h1:NO/8qkisMZLZ1FCsKNqtJPwc8/TaclWyY0B6wcYNg9M=
242244
go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
245+
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
243246
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
244247
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
245248
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=

0 commit comments

Comments
 (0)