Esempio n. 1
0
func (worker *Worker) registerClients() {
	worker.clients = make(map[string]*http.Client)
	for i := range worker.info.Oauths {
		oinfo := worker.info.Oauths[i]
		oauth := NewOauth(oinfo.AppKey, oinfo.AppSecret, oinfo.Token, oinfo.Secret)
		if oauth == nil {
			continue
		}

		if _, ok := worker.clients[oinfo.Name]; !ok {
			worker.clients[oinfo.Name] = oauth
		} else {
			util.Warning("double register client for oauth %s\n", oinfo.Name)
		}
	}
}
Esempio n. 2
0
func (worker *Worker) registerDatabase() {
	worker.databases = make(map[string]NanduDB)
	for i := range worker.info.Databases {
		dinfo := worker.info.Databases[i]
		database := NewDatabase(dinfo.DbType, dinfo.ConnectStr)
		if database == nil {
			continue
		}

		if _, ok := worker.databases[dinfo.Name]; !ok {
			worker.databases[dinfo.Name] = NanduDB{database, dinfo.Init}
		} else {
			util.Warning("double register database %s\n", dinfo.Name)
		}
	}
}