func newJobQueue(interval time.Duration) *jobQueue {
	jq := &jobQueue{
		interval:     interval,
		stop:         make(chan bool),
		stopped:      make(chan bool),
		health:       health.RegisterLiveness(fmt.Sprintf("collector-queue-%vs", interval.Seconds())),
		bucketTicker: time.NewTicker(time.Second),
	}

	var nb int
	if interval <= time.Second {
		nb = 1
	} else {
		nb = int(interval.Truncate(time.Second).Seconds())
	}
	for i := 0; i < nb; i++ {
		bucket := &jobBucket{}
		jq.buckets = append(jq.buckets, bucket)
	}

	// compute step for sparse scheduling
	if nb <= 2 {
		jq.sparseStep = uint(1)
	} else {
		switch nb % 2 {
		case 0:
			step := nb / 2
			switch step % 2 {
			case 0:
				jq.sparseStep = uint(step - 1)
			case 1:
				jq.sparseStep = uint(step - 2)
			}
		case 1:
			jq.sparseStep = uint(nb / 2)
		}
	}

	return jq
}
// newJobQueue creates a new jobQueue instance
newJobQueue creates a new jobQueue instance
// newJobQueue creates a new jobQueue instance
func newJobQueue(interval time.Duration) *jobQueue {
	jq := &jobQueue{
		interval:     interval,
		stop:         make(chan bool),
		stopped:      make(chan bool),
		health:       health.RegisterLiveness(fmt.Sprintf("collector-queue-%vs", interval.Seconds())),
		bucketTicker: time.NewTicker(time.Second),
	}
	var nb int
	if interval <= time.Second {
		nb = 1
	} else {
		nb = int(interval.Truncate(time.Second).Seconds())
	}
	for i := 0; i < nb; i++ {
		bucket := &jobBucket{}
		jq.buckets = append(jq.buckets, bucket)
	}
	if nb <= 2 {
		jq.sparseStep = uint(1)
	} else {
		switch nb % 2 {
		case 0:
			step := nb / 2
			switch step % 2 {
			case 0:
				jq.sparseStep = uint(step - 1)
			case 1:
				jq.sparseStep = uint(step - 2)
			}
		case 1:
			jq.sparseStep = uint(nb / 2)
		}
	}
	return jq
}
func newJobQueue ( interval time . Duration ) * jobQueue { jq := & jobQueue { interval : interval , stop : make ( chan bool ) , stopped : make ( chan bool ) , health : health . RegisterLiveness ( fmt . Sprintf ( " " , interval . Seconds ( ) ) ) , bucketTicker : time . NewTicker ( time . Second ) , } var nb int if interval <= time . Second { nb = 1 } else { nb = int ( interval . Truncate ( time . Second ) . Seconds ( ) ) } for i := 0 ; i < nb ; i ++ { bucket := & jobBucket { } jq . buckets = append ( jq . buckets , bucket ) } if nb <= 2 { jq . sparseStep = uint ( 1 ) } else { switch nb % 2 { case 0 : step := nb / 2 switch step % 2 { case 0 : jq . sparseStep = uint ( step - 1 ) case 1 : jq . sparseStep = uint ( step - 2 ) } case 1 : jq . sparseStep = uint ( nb / 2 ) } } return jq }
newJobQueue creates a new jobQueue instance
newJobQueue creates a new jobQueue instance
// compute step for sparse scheduling