func (s *Scorer) ScoreManager() chan Update {
	updates := make(chan Update)
	log.Info("Starting ScoreManager")
	if s.DryRun {
		log.Info("DryRun, NOOP mode")
	}
	printTicker := time.NewTicker(s.UpdateInterval)
	evaluateTicker := time.NewTicker(s.EvaluateInterval)
	resetTimer := time.NewTicker(s.ResetInterval)
	go func() {
		for {
			select {
			case <-evaluateTicker.C:
				metrics.Mark("score.evaluates")
				go s.EvaluateApps()
			case <-printTicker.C:
				go s.printScores()
			case <-resetTimer.C:
				metrics.Mark("score.resets")
				go s.resetScores()
			case u := <-updates:
				metrics.UpdateGauge("score.updateQueue", int64(len(updates)))
				go s.initOrUpdateScore(u)
			}
		}
	}()
	return updates
}
ScoreManager starts Scorer job
package score
import (
	"errors"
	"fmt"
	"sync"
	"time"
	log "github.com/Sirupsen/logrus"
	"github.com/allegro/marathon-appcop/marathon"
	"github.com/allegro/marathon-appcop/metrics"
)
type Score struct {
	score      int
	lastUpdate time.Time
}
type Scorer struct {
	mutex            sync.RWMutex
	ScaleDownScore   int
	ResetInterval    time.Duration
	UpdateInterval   time.Duration
	EvaluateInterval time.Duration
	DryRun           bool
	ScaleLimit       int
	service          marathon.Marathoner
	scores           map[marathon.AppID]*Score
}
type Update struct {
	App    *marathon.App
	Update int
}
func New(config Config, m marathon.Marathoner) (*Scorer, error) {
	if config.ResetInterval <= config.UpdateInterval {
		return nil, errors.New("UpdateInterval should be lower than ResetInterval")
	}
	if config.ResetInterval <= config.EvaluateInterval {
		return nil, errors.New("ResetInterval should be lower than EvaluateInterval")
	}
	return &Scorer{
		ScaleDownScore:   config.ScaleDownScore,
		ResetInterval:    config.ResetInterval,
		UpdateInterval:   config.UpdateInterval,
		EvaluateInterval: config.EvaluateInterval,
		ScaleLimit:       config.ScaleLimit,
		DryRun:           config.DryRun,
		service:          m,
		scores:           make(map[marathon.AppID]*Score),
	}, nil
}