Beispiel #1
0
func NewSubmissionServer(s store.Store) *submitState {
	resultsChan := make(chan *store.Result)
	go s.WriteResults(resultsChan)

	return &submitState{
		results: resultsChan,
	}
}
Beispiel #2
0
func NewTaskServer(s store.Store, serverUrl, templatesPath, geoipDatabase string) *measurementsServerState {
	queries := make(chan *store.Query)
	go s.WriteQueries(queries)

	measurementIds := generateMeasurementIds()

	go s.ScheduleTaskFunctions()

	taskRequests := make(chan *store.TaskRequest)
	go s.Tasks(taskRequests)

	countResultsRequests := make(chan store.CountResultsRequest)
	go s.CountResultsForReferrer(countResultsRequests)

	geolocator, err := geoip.Open(geoipDatabase)
	if err != nil {
		log.Fatalf("error opening geoip database: %v", err)
	}

	return &measurementsServerState{
		Store:                s,
		Templates:            template.Must(template.ParseGlob(filepath.Join(templatesPath, "[a-zA-Z]*"))),
		Queries:              queries,
		MeasurementIds:       measurementIds,
		TaskRequests:         taskRequests,
		CountResultsRequests: countResultsRequests,
		ServerUrl:            serverUrl,
		Geolocator:           geolocator,
	}
}
Beispiel #3
0
func NewStatsServer(s store.Store, templatesPath string) http.Handler {
	countResultsRequests := make(chan store.CountResultsRequest)
	go s.CountResultsForReferrer(countResultsRequests)

	resultsPerDayRequests := make(chan store.ResultsPerDayRequest)
	go s.ResultsPerDayForReferrer(resultsPerDayRequests)

	resultsPerCountryRequests := make(chan store.ResultsPerCountryRequest)
	go s.ResultsPerCountryForReferrer(resultsPerCountryRequests)

	return &statsState{
		CountResultsRequests:      countResultsRequests,
		ResultsPerDayRequests:     resultsPerDayRequests,
		ResultsPerCountryRequests: resultsPerCountryRequests,
	}
}
Beispiel #4
0
func NewTaskServer(s store.Store, serverUrl, templatesPath string) *measurementsServerState {
	queries := make(chan *store.Query)
	go s.WriteQueries(queries)

	measurementIds := generateMeasurementIds()

	go s.ScheduleTaskGroups()

	taskGroups := s.TaskGroups()

	countResultsRequests := make(chan store.CountResultsRequest)
	go s.CountResultsForReferrer(countResultsRequests)

	return &measurementsServerState{
		Store:                s,
		Templates:            template.Must(template.ParseGlob(filepath.Join(templatesPath, "[a-zA-Z]*"))),
		Queries:              queries,
		MeasurementIds:       measurementIds,
		TaskGroups:           taskGroups,
		CountResultsRequests: countResultsRequests,
		ServerUrl:            serverUrl,
	}
}