[🚀] v0.12.21
This commit is contained in:
@ -12,12 +12,15 @@ import (
|
||||
)
|
||||
|
||||
type clientConfig struct {
|
||||
client agollo.Client
|
||||
ac *apolloConfig.AppConfig
|
||||
conf any
|
||||
client agollo.Client
|
||||
ac *apolloConfig.AppConfig
|
||||
onChange func(event *storage.ChangeEvent)
|
||||
|
||||
onChange func(event *storage.ChangeEvent)
|
||||
onNewestChange func(*storage.FullChangeEvent)
|
||||
|
||||
conf any
|
||||
cluster string
|
||||
addr string
|
||||
}
|
||||
|
||||
type Option func(*clientConfig)
|
||||
@ -34,24 +37,38 @@ func WithOnNewestChangeEvent(event func(event *storage.FullChangeEvent)) Option
|
||||
}
|
||||
}
|
||||
|
||||
func WithCluster(cluster string) Option {
|
||||
return func(conf *clientConfig) {
|
||||
conf.cluster = cluster
|
||||
}
|
||||
}
|
||||
|
||||
func WithAddr(addr string) Option {
|
||||
return func(conf *clientConfig) {
|
||||
conf.addr = addr
|
||||
}
|
||||
}
|
||||
|
||||
func GetApolloConfig(appId, secret string, config any, opt ...Option) error {
|
||||
var err error
|
||||
c := &clientConfig{
|
||||
cluster: "dev",
|
||||
addr: "https://config.bvbej.com",
|
||||
conf: config,
|
||||
}
|
||||
for _, option := range opt {
|
||||
option(c)
|
||||
}
|
||||
namespace := env.Active().Value() + ".yaml"
|
||||
|
||||
c := new(clientConfig)
|
||||
c.conf = config
|
||||
c.ac = &apolloConfig.AppConfig{
|
||||
AppID: appId,
|
||||
Cluster: "dev",
|
||||
IP: "https://config.bvbej.com",
|
||||
Cluster: c.cluster,
|
||||
IP: c.addr,
|
||||
NamespaceName: namespace,
|
||||
IsBackupConfig: false,
|
||||
Secret: secret,
|
||||
MustStart: true,
|
||||
}
|
||||
for _, option := range opt {
|
||||
option(c)
|
||||
}
|
||||
|
||||
agollo.SetLogger(&log.DefaultLogger{})
|
||||
|
||||
|
Reference in New Issue
Block a user