示例#1
0
func NewDataProvider(initiateData dataproviders.InitiateData,
	term dataproviders.TerminateCallback,
	client *http.Client,
	pvStore dataproviders.PvStore,
	statsStore dataproviders.PlantStatsStore) dataProvider {
	log.Debug("New dataprovider")

	dp := dataProvider{initiateData,
		nil,
		client}
	go dataproviders.RunUpdates(
		&initiateData,
		func(initiateData *dataproviders.InitiateData, pv *dataproviders.PvData) error {
			err := updatePvData(client, initiateData, pv)
			pv.LatestUpdate = nil
			return err
		},
		func(initiateData *dataproviders.InitiateData, pv *dataproviders.PvData) error {
			return nil
		},
		time.Second*10,
		time.Minute*5,
		time.Minute*30,
		term,
		MAX_ERRORS,
		statsStore,
		pvStore)

	return dp
}
示例#2
0
func NewDataProvider(initiateData dataproviders.InitiateData,
	term dataproviders.TerminateCallback,
	client *http.Client,
	pvStore dataproviders.PvStore,
	statsStore dataproviders.PlantStatsStore) dataProvider {
	log.Debug("New dataprovider")

	dp := dataProvider{initiateData,
		//		make(chan chan dataproviders.PvData),
		//		make(chan dataproviders.PvData),
		//		make(chan int),
		nil,
		client}
	go dataproviders.RunUpdates(
		&initiateData,
		func(initiateData *dataproviders.InitiateData, pv *dataproviders.PvData) error {
			err := updatePvData(client, initiateData, pv)
			pv.LatestUpdate = nil
			return err
		},
		func(initiateData *dataproviders.InitiateData, pv *dataproviders.PvData) error {
			return nil
		},
		time.Minute*1,
		time.Minute*5,
		time.Minute*30,
		term,
		MAX_ERRORS,
		statsStore,
		pvStore)
	//	go dataproviders.LatestPvData(dp.latestReqCh, dp.latestUpdateCh, dp.terminateCh,
	//		pvDataUpdatedEvent, initiateData.PlantKey)

	return dp
}