Example #1
0
func (self *SrcManage) Push(req *context.Request) {
	if spiderId, ok := req.GetSpiderId(); ok {
		priority := int(req.GetPriority())
		if priority > MAX_PRIORITY {
			priority = MAX_PRIORITY
		}

		for i, x := 0, priority+1-len(self.queue[spiderId]); i < x; i++ {
			self.queue[spiderId] = append(self.queue[spiderId], []*context.Request{})
		}

		self.queue[spiderId][priority] = append(self.queue[spiderId][priority], req)
	}
}
Example #2
0
func (self *SrcManage) Push(req *context.Request) {
	if spiderId, ok := req.GetSpiderId(); ok {
		self.queue[spiderId] = append(self.queue[spiderId], req)
	}
}