mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
* version updates * up * add watch feature for package kubecm * feat: support apollo as Adapter (#2143) * feat: support apollo as Adapter * feat: support apollo as Adapter * feat: support apollo as Adapter * feat: test apollo Adapter * feat: test apollo Adapter Co-authored-by: hongyihui <hongyihui@lixiang.com> Co-authored-by: houseme <housemecn@gmail.com> Co-authored-by: John Guo <john@johng.cn> * add gcfg.Adapter implements using apollo service * ci yaml update for apollo Co-authored-by: hong0220 <hong0220@users.noreply.github.com> Co-authored-by: hongyihui <hongyihui@lixiang.com> Co-authored-by: houseme <housemecn@gmail.com>
28 lines
578 B
Go
28 lines
578 B
Go
package boot
|
|
|
|
import (
|
|
"github.com/gogf/gf/contrib/config/apollo/v2"
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
"github.com/gogf/gf/v2/os/gctx"
|
|
)
|
|
|
|
func init() {
|
|
var (
|
|
ctx = gctx.GetInitCtx()
|
|
appId = "SampleApp"
|
|
cluster = "default"
|
|
ip = "http://localhost:8080"
|
|
)
|
|
// Create apollo Client that implements gcfg.Adapter.
|
|
adapter, err := apollo.New(ctx, apollo.Config{
|
|
AppID: appId,
|
|
IP: ip,
|
|
Cluster: cluster,
|
|
})
|
|
if err != nil {
|
|
g.Log().Fatalf(ctx, `%+v`, err)
|
|
}
|
|
// Change the adapter of default configuration instance.
|
|
g.Cfg().SetAdapter(adapter)
|
|
}
|