コード例 #1
0
// New creates a new Summary.
//
// The Summary listens for change events from the tallies object
// and calculates new paramsets on every event.
func New(tallies *tally.Tallies, storages *storage.Storage) *Summary {
	byTrace, byTraceIncludeIgnored, err := oneStep(tallies, storages)
	if err != nil {
		glog.Fatalf("Failed to calculate first step of paramsets: %s", err)
	}

	s := &Summary{
		byTrace:               byTrace,
		byTraceIncludeIgnored: byTraceIncludeIgnored,
		tallies:               tallies,
		storages:              storages,
	}

	tallies.OnChange(s.updateParamSets)
	return s
}
コード例 #2
0
ファイル: summary.go プロジェクト: saltmueller/skia-buildbot
// New creates a new instance of Summaries.
func New(storages *storage.Storage, tallies *tally.Tallies, blamer *blame.Blamer) (*Summaries, error) {
	s := &Summaries{
		storages: storages,
		tallies:  tallies,
		blamer:   blamer,
	}

	var err error
	s.summaries, err = s.CalcSummaries(nil, "", false, true)
	if err != nil {
		return nil, fmt.Errorf("Failed to calculate summaries in New: %s", err)
	}

	// TODO(jcgregorio) Move to a channel for tallies and then combine
	// this and the expStore handling into a single switch statement.
	tallies.OnChange(func() {
		summaries, err := s.CalcSummaries(nil, "", false, true)
		if err != nil {
			glog.Errorf("Failed to refresh summaries: %s", err)
			return
		}
		s.mutex.Lock()
		s.summaries = summaries
		s.mutex.Unlock()
	})

	storages.EventBus.SubscribeAsync(expstorage.EV_EXPSTORAGE_CHANGED, func(e interface{}) {
		testNames := e.([]string)
		glog.Info("Updating summaries after expectations change.")
		partialSummaries, err := s.CalcSummaries(testNames, "", false, true)
		if err != nil {
			glog.Errorf("Failed to refresh summaries: %s", err)
			return
		}
		s.mutex.Lock()
		for k, v := range partialSummaries {
			s.summaries[k] = v
		}
		s.mutex.Unlock()
	})
	return s, nil
}