예제 #1
0
func pipePlug(i plug.Plug, o plug.Plug) {
	for c := range i.Changes() {
		if err := o.Send(c.String()); err != nil {
			log.Error(err)
		}
	}
}
예제 #2
0
func runPlug(k string, p plug.Plug) {
	for {
		log.Infof("Plug '%s' is connecting...", k)
		if err := p.Connect(); err != nil {
			log.Error(err)
			<-time.After(5 * time.Second)
			continue
		}
		log.Infof("Plug '%s' connected", k)
		p.Loop()
		log.Infof("Plug '%s' unlocked after loop", k)
		<-time.After(5 * time.Second)
	}
}