Skip to content

Commit

Permalink
Merge pull request #94 from shawnfeng/mod/cache_config
Browse files Browse the repository at this point in the history
Mod/cache config
  • Loading branch information
kylin2017 authored Sep 3, 2019
2 parents d4993c3 + 821ee15 commit 41b7d07
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 8 deletions.
9 changes: 8 additions & 1 deletion cache/redisext/redisext.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,12 @@ func WatchUpdate(ctx context.Context) {
}

func init() {
_ = SetConfiger(context.Background(), cache.ConfigerTypeSimple)
fun := "redisext.init -->"
ctx := context.Background()
err := SetConfiger(ctx, cache.ConfigerTypeApollo)
if err != nil {
slog.Errorf(ctx, "%s set redisext configer:%v err:%v", fun, cache.ConfigerTypeApollo, err)
} else {
slog.Infof(ctx, "%s redisext configer:%v been set", fun, cache.ConfigerTypeApollo)
}
}
9 changes: 8 additions & 1 deletion cache/value/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,12 @@ func WatchUpdate(ctx context.Context) {
}

func init() {
_ = SetConfiger(context.Background(), cache.ConfigerTypeSimple)
fun := "value.init -->"
ctx := context.Background()
err := SetConfiger(ctx, cache.ConfigerTypeApollo)
if err != nil {
slog.Errorf(ctx, "%s set cache configer:%v err:%v", fun, cache.ConfigerTypeApollo, err)
} else {
slog.Infof(ctx, "%s cache configer:%v been set", fun, cache.ConfigerTypeApollo)
}
}
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module github.com/shawnfeng/sutil

require (
github.com/ZhengHe-MD/agollo v0.0.0-20190716115826-871879c67d2c
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/ZhengHe-MD/agollo/v4 v4.1.3
github.com/ZhengHe-MD/properties v0.2.1
github.com/bitly/go-simplejson v0.4.4-0.20140701141959-3378bdcb5ceb
github.com/coreos/etcd v3.0.0-beta.0.0.20160712024141-cc26f2c8892e+incompatible
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ github.com/ZhengHe-MD/agollo v0.0.0-20190716115826-871879c67d2c h1:JqNcZdgvS1L0D
github.com/ZhengHe-MD/agollo v0.0.0-20190716115826-871879c67d2c/go.mod h1:Hs1VYbuOoVlDPOMlZawvwpN7eAqDOQUFG3Lxcne0SBo=
github.com/ZhengHe-MD/agollo v2.1.0+incompatible h1:NqugIJRTEPNLBtzg3TkM2rfUnpwNRgkhy0Mhk3yJ0Es=
github.com/ZhengHe-MD/agollo v2.1.0+incompatible/go.mod h1:Hs1VYbuOoVlDPOMlZawvwpN7eAqDOQUFG3Lxcne0SBo=
github.com/ZhengHe-MD/agollo/v4 v4.1.3 h1:qsJ6oWrb+tYp16RUS2X3Ez6yE3f55y1rYlxdcRWvMkQ=
github.com/ZhengHe-MD/agollo/v4 v4.1.3/go.mod h1:Cze1dOFujMfuqY5mZWzz1vvJ0ZdpDQ77PC5m2J/qv+4=
github.com/ZhengHe-MD/properties v0.0.1 h1:o/BdossbmWdoD0T5jhEW3ty77q1Yy106uefvV1GDPQc=
github.com/ZhengHe-MD/properties v0.0.1/go.mod h1:6d7Dapy6sSqC/QRwv8HTZ7h6yxvYQsyIcKBdYJJbyLE=
github.com/ZhengHe-MD/properties v0.0.2 h1:+ZlfMUFN0rrTEjSsSvdZmwwvry6tHVq036k5KIsbYuM=
Expand Down
10 changes: 8 additions & 2 deletions mq/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ func Close() {
}

func init() {
// set default config type to simple
_ = SetConfiger(context.Background(), ConfigerTypeSimple)
fun := "mq.init -->"
ctx := context.Background()
err := SetConfiger(ctx, ConfigerTypeApollo)
if err != nil {
slog.Errorf(ctx, "%s set mq configer:%v err:%v", fun, ConfigerTypeApollo, err)
} else {
slog.Infof(ctx, "%s mq configer:%v been set", fun, ConfigerTypeApollo)
}
}
2 changes: 1 addition & 1 deletion sconf/center/apollo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package center

import (
"context"
"github.com/ZhengHe-MD/agollo"
"github.com/ZhengHe-MD/agollo/v4"
"github.com/ZhengHe-MD/properties"
"github.com/opentracing/opentracing-go"
"github.com/shawnfeng/sutil/slog/slog"
Expand Down
2 changes: 1 addition & 1 deletion sconf/center/change.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package center

import (
"github.com/ZhengHe-MD/agollo"
"github.com/ZhengHe-MD/agollo/v4"
"github.com/pkg/errors"
)

Expand Down
2 changes: 1 addition & 1 deletion slog/slog/slog.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@ func GetLogger() *Logger {
}

func (m *Logger) Printf(format string, v ...interface{}) {
Errorf(context.Background(), format, v...)
Infof(context.Background(), format, v...)
}

0 comments on commit 41b7d07

Please sign in to comment.