-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.go
37 lines (35 loc) · 878 Bytes
/
boot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package boot
import (
"github.com/joy12825/gf/frame/g"
"github.com/joy12825/gf/os/gctx"
"github.com/nacos-group/nacos-sdk-go/common/constant"
"github.com/nacos-group/nacos-sdk-go/vo"
)
func init() {
var (
ctx = gctx.GetInitCtx()
serverConfig = constant.ServerConfig{
IpAddr: "localhost",
Port: 8848,
}
clientConfig = constant.ClientConfig{
CacheDir: "/tmp/nacos",
LogDir: "/tmp/nacos",
}
configParam = vo.ConfigParam{
DataId: "config.toml",
Group: "test",
}
)
// Create nacos Client that implements gcfg.Adapter.
adapter, err := nacos.New(ctx, nacos.Config{
ServerConfigs: []constant.ServerConfig{serverConfig},
ClientConfig: clientConfig,
ConfigParam: configParam,
})
if err != nil {
g.Log().Fatalf(ctx, `%+v`, err)
}
// Change the adapter of default configuration instance.
g.Cfg().SetAdapter(adapter)
}