Example #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
}
Example #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
}
Example #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
}
Example #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()
		}
	}
}