Ejemplo n.º 1
0
// Run the service
func (self *Service) Run() error {
	gr = graphite.New(services.Config.Graphite.Host)
	// schedule at given time and interval
	ticker := util.NewScheduler(services.Config.Irrigation.At.Duration,
		services.Config.Irrigation.Interval.Duration)
	for t := range ticker.C {
		tick(t)
	}
	return nil
}
Ejemplo n.º 2
0
// Run the service
func (self *Service) Run() error {
	// initialise
	gr = graphite.New(services.Config.Graphite.Host)

	// schedule at 00:02
	offset, _ := time.ParseDuration("2m")
	repeat, _ := time.ParseDuration("24h")
	ticker := util.NewScheduler(offset, repeat)
	for t := range ticker.C {
		tick(t)
	}
	return nil
}
Ejemplo n.º 3
0
// Run the service
func (self *Service) Run() error {
	self.thermo = NewThermostat(services.Config.Heating, services.Publisher)
	ticker := util.NewScheduler(time.Duration(0), time.Minute)
	events := services.Subscriber.FilteredChannel("temp", "house", "command")
	for {
		select {
		case ev := <-events:
			self.thermo.Event(ev)
		case tick := <-ticker.C:
			self.thermo.Heartbeat(tick)
		}
	}
	return nil
}
Ejemplo n.º 4
0
// Run the service
func (service *Service) Run() error {
	gr = graphite.New(services.Config.Graphite.Host)
	// schedule at 08:00
	offset, _ := time.ParseDuration("8h")
	repeat, _ := time.ParseDuration("24h")
	ticker := util.NewScheduler(offset, repeat)
	events := services.Subscriber.FilteredChannel("rain", "temp", "wind")
	for {
		select {
		case ev := <-events:
			checkEvent(ev)
		case <-ticker.C:
			tick()
		}
	}
}