Example #1
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,
	}
}
Example #2
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,
	}
}