[🚀] v0.12.21

This commit is contained in:
2025-02-27 15:00:51 +08:00
parent 3e5f407402
commit 388efae2ca
7 changed files with 141 additions and 135 deletions

View File

@ -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{})