Exemple #1
0
// 更新或加入失败记录
// 对比是否已存在,不存在就记录
func (self *Failure) UpsertFailure(req *context.Request) bool {
	self.RWMutex.Lock()
	defer self.RWMutex.Unlock()

	spName := req.GetSpiderName()
	s := req.Serialize()

	if failures, ok := self.list[spName]; !ok {
		self.list[spName] = make(map[string]bool)
	} else if failures[s] {
		return false
	}

	self.list[spName][s] = true
	return true
}
Exemple #2
0
// 删除失败记录
func (self *Failure) DeleteFailure(req *context.Request) {
	self.RWMutex.Lock()
	s := req.Serialize()
	delete(self.list[req.GetSpiderName()], s)
	self.RWMutex.Unlock()
}