示例#1
0
func (this *Updater) Process(log_id string, body []byte, params map[string]string, result map[string]interface{}, ftime func(string) string) error {

	this.Logger.Info("Update...")
	var updateInfo builder.UpdateInfo
	info := make(map[string]string)
	info["id"] = "154"
	info["cid"] = "146"
	info["name"] = "吴坚"
	info["email"] = "*****@*****.**"
	info["address"] = "ABCADDRESS"
	info["city"] = "Changsha"
	info["country"] = "USA"
	info["sex"] = "1"
	info["mobile_phone"] = "13232"
	info["last_modify_time"] = "2015-01-01 00:11:22"
	updateInfo.Info = info
	updateInfo.IsProfile = false
	updateInfo.ErrChan = make(chan error)
	this.Data_chan <- updateInfo

	errinfo := <-updateInfo.ErrChan

	if errinfo != nil {
		this.Logger.Info("Update Fail.... %v ", errinfo)
	} else {
		this.Logger.Info("Update success....")
	}
	//this.Indexer.UpdateRecord(info,false)
	//this.Indexer.Display()
	return nil
}
示例#2
0
func (this *Updater) Process(log_id string, body []byte, params map[string]string, result map[string]interface{}, ftime func(string) string) error {

	this.Logger.Info("Update...")
	var updateInfo builder.UpdateInfo
	info := make(map[string]string)
	info["id"] = "154"
	info["cid"] = "188"
	info["name"] = "吴坚"
	info["email"] = "*****@*****.**"
	info["address"] = "ABCADDRESS"
	info["age"] = "4506"
	info["mobile_phone"] = "8897"
	info["last_modify_time"] = "2015-01-01 00:11:22"
	updateInfo.Info = info
	updateInfo.UpdateType = 1
	updateInfo.ErrChan = make(chan error)
	this.Data_chan <- updateInfo
	errinfo := <-updateInfo.ErrChan
	if errinfo != nil {
		this.Logger.Info("Update Fail.... %v ", errinfo)
	} else {
		this.Logger.Info("Update success....")
	}

	info["id"] = "1564"
	info["name"] = "吴yyuu坚"
	updateInfo.Info = info
	updateInfo.UpdateType = 1
	updateInfo.ErrChan = make(chan error)
	this.Data_chan <- updateInfo
	errinfo = <-updateInfo.ErrChan
	if errinfo != nil {
		this.Logger.Info("Update Fail.... %v ", errinfo)
	} else {
		this.Logger.Info("Update success....")
	}

	for i := 0; i < 10; i++ {
		info["id"] = "1594"
		info["cid"] = "999"
		updateInfo.Info = info
		updateInfo.UpdateType = 1
		updateInfo.ErrChan = make(chan error)
		this.Data_chan <- updateInfo
		errinfo = <-updateInfo.ErrChan
		if errinfo != nil {
			this.Logger.Info("Update Fail.... %v ", errinfo)
		} else {
			this.Logger.Info("Update success....")
		}

	}

	return nil
}
示例#3
0
func (this *Updater) Process(log_id string, body []byte, params map[string]string, result map[string]interface{}, ftime func(string) string) error {

	//this.Logger.Info("Update...")
	var updateInfo builder.UpdateInfo
	/*info := make(map[string]string)
	fmt.Printf("BODY : %v \n",body)
	err := json.Unmarshal(body, info)
	if err != nil {
		fmt.Printf("Unmarshal Error ...\n")
		return err
	}*/
	updateInfo.Info = params
	updateInfo.UpdateType = 0
	updateInfo.ErrChan = make(chan error)
	updateInfo.LogId = log_id
	this.Data_chan <- updateInfo
	errinfo := <-updateInfo.ErrChan
	if errinfo != nil {
		this.Logger.Info("Update Fail.... %v ", errinfo)
	} else {
		this.Logger.Info("Update success....")
	}
	/*
		var updateInfo builder.UpdateInfo
		info := make(map[string]string)
		info["id"] = "154"
		info["cid"] = "188"
		info["name"] = "吴坚"
		info["email"] = "*****@*****.**"
		info["address"] = "ABCADDRESS"
		info["age"] = "4506"
		info["mobile_phone"] = "8897"
		info["last_modify_time"] = "2015-01-01 00:11:22"
		updateInfo.Info = info
		updateInfo.UpdateType = 1
		updateInfo.ErrChan = make(chan error)
		this.Data_chan <- updateInfo
		errinfo := <-updateInfo.ErrChan
		if errinfo != nil {
			this.Logger.Info("Update Fail.... %v ", errinfo)
		} else {
			this.Logger.Info("Update success....")
		}
		info["id"] = "1564"
		info["name"] = "吴yyuu坚"
		updateInfo.Info = info
		updateInfo.UpdateType = 1
		updateInfo.ErrChan = make(chan error)
		this.Data_chan <- updateInfo
		errinfo = <-updateInfo.ErrChan
		if errinfo != nil {
			this.Logger.Info("Update Fail.... %v ", errinfo)
		} else {
			this.Logger.Info("Update success....")
		}

		for i := 0; i < 10; i++ {
			info["id"] = "1594"
			info["cid"] = "999"
			updateInfo.Info = info
			updateInfo.UpdateType = 1
			updateInfo.ErrChan = make(chan error)
			this.Data_chan <- updateInfo
			errinfo = <-updateInfo.ErrChan
			if errinfo != nil {
				this.Logger.Info("Update Fail.... %v ", errinfo)
			} else {
				this.Logger.Info("Update success....")
			}

		}
	*/
	//this.Indexer.UpdateRecord(info,false)
	//this.Indexer.Display()
	return nil
}