master
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
1 branch 0 tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
go get -u github.com/cihub/seelog
go get -u github.com/coocood/freecache
go get -u github.com/welcome112s/apollo-go-sdk
{
    "appId":"app-capability",
    "cluster":"default",
    "metaServer":"http://10.160.1.153:8083",
    "httpRefreshInterval":"300s",
    "httpTimeout":"20s",
    "onErrorRetryInterval":"1s",
    "maxConfigCacheSize":52428800,
    "configCacheExpireTime":60,
    "longPollingRefreshInterval":"2s",
    "longPollingTimeout":"60s"
}
使用前调用方法:
apollosdk.Start("/opt/config.json","appId","cluster","metaServer","dataCenter")
apollosdk.Start("/opt/config.json","appId","cluster","metaServer","dataCenter")
config := apollosdk.GetAppConfig()
config.GetStringProperty("mats", "")

config := apollosdk.GetConfig(""app.tc.mat.disable"")
config.GetStringProperty("mats", "")
configNew := apollosdk.GetConfig(""app.tc.mat.disable"")
//方式一:定义变量来监听
var varFunc OnChangeFunc =  func (changeEvent ConfigChangeEvent)  {
		fmt.Println("variable onChange",changeEvent)
}
configNew.AddChangeListenerFunc(varFunc)


//方式二:定义普通函数来监听
func onTestFunc(changeEvent ConfigChangeEvent) {
	fmt.Println("func onChange",changeEvent)
}
configNew.AddChangeListenerFunc(onTestFunc)

//方式三:定义结构实现接口来监听
type SomeThing string

func (s SomeThing)OnChange (changeEvent ConfigChangeEvent)  {
	fmt.Println("struct onChange",changeEvent)
}
var s SomeThing = "s"
configNew.AddChangeListener(s)

//移除监听器
configNew.RemoveChangeListener(s)
 appsdk1:= apollosdk.NewApolloSdk(core.CConfig{
    AppId:       "app1",
    Cluster:     "",
    MmetaServer: "",
    DataCenter:  "",
  })

 appsdk2:=apollosdk.NewApolloSdk(core.CConfig{
   AppId:       "app2",
   Cluster:     "",
   MmetaServer: "",
   DataCenter:  "",
 })