Exemple #1
0
func (this *FileMgr) run() {
	exitNotify := this.waitGroup.ExitNotify()
	for {
		select {
		case <-exitNotify:
			return
		case <-this.expiredTimer:
			if err := this.RemoveExpiredFile(); err != nil {
				syslog.Warn(err)
			}
		case file := <-this.fileCh:
			if err := addFile(file); err != nil {
				syslog.Warn(err, *file)
			}

		}
	}
}
Exemple #2
0
func (this *nsqdMgr) producer(idx int) {
	this.waitGroup.Add(1)
	defer this.waitGroup.Done()
	exitNotify := this.waitGroup.ExitNotify()

	for {
		select {
		case <-exitNotify:
			return
		case msg := <-this.msgCh:
			if err := this.producers[idx].Publish(msg.topic, msg.body); err != nil {
				syslog.Warn("Publish failed!!! ", err, msg.topic, string(msg.body))
				//投递失败,返回队列让其它链接投递
				this.msgCh <- msg
			}
		}
	}
}