Exemple #1
0
// 对比是否已存在,不存在则采样
func (self *Deduplication) Compare(obj interface{}) bool {
	s := util.MakeUnique(obj)
	if !self.sampling[s] {
		self.sampling[s] = true
		return false
	}
	return true
}
Exemple #2
0
// 取消指定去重样本
func (self *Deduplication) Remove(obj interface{}) {
	self.Mutex.Lock()
	defer self.Unlock()

	s := util.MakeUnique(obj)
	if self.sampling[s] {
		delete(self.sampling, s)
	}
}
Exemple #3
0
// 更新或加入成功记录
// 对比是否已存在,不存在就记录
func (self *Success) UpsertSuccess(record Record) bool {
	self.RWMutex.Lock()
	defer self.RWMutex.Unlock()

	s := util.MakeUnique(record.GetUrl() + record.GetMethod())
	if self.old[s] {
		return false
	}
	if self.new[s] {
		return false
	}
	self.new[s] = true
	return true
}
Exemple #4
0
// 对比是否已存在,不存在则采样
func (self *Deduplication) Compare(obj interface{}) (duplicate bool) {
	self.Mutex.Lock()
	defer self.Unlock()

	s := util.MakeUnique(obj)
	if self.sampling.old[s] {
		return true
	}
	if self.sampling.new[s] {
		return true
	}
	self.sampling.new[s] = true
	return false
}
Exemple #5
0
func makeUnique(req *context.Request) string {
	return util.MakeUnique(req.GetUrl() + req.GetMethod())
}
Exemple #6
0
// 删除成功记录
func (self *Success) DeleteSuccess(record Record) {
	self.RWMutex.Lock()
	s := util.MakeUnique(record.GetUrl() + record.GetMethod())
	delete(self.new, s)
	self.RWMutex.Unlock()
}