// Pay attention to the events coming off the local syncthing server to update
// state and reload the remote container if required.
Pay attention to the events coming off the local syncthing server to update
state and reload the remote container if required.
// Pay attention to the events coming off the local syncthing server to update // state and reload the remote container if required .
func (f *Folder) watchEvents() error {
	stream, err := f.localServer.Events()
	if err != nil {
		return err
	}
	go func() {
		for ev := range stream {
			data := ev.Data.(map[string]interface{})
			if val, ok := data["folder"]; !ok || (ok && (f.id != val)) {
				continue
			}
			switch ev.Type {
			case events.FolderSummary:
				log.WithFields(f.ShortFields()).Info("updating")
				f.Status = ServiceUpdating
			case events.FolderCompletion:
				log.WithFields(f.ShortFields()).Info("update complete")
				f.Status = ServiceWatching
				if f.Reload {
					f.restartContainer <- true
				}
			}
		}
		log.WithFields(f.Fields()).Debug("cleaning up event handler")
	}()
	return nil
}
func ( f * Folder ) watchEvents ( ) error { stream , err := f . localServer . Events ( ) if err != nil { return err } go func ( ) { for ev := range stream { data := ev . Data . ( map [ string ] interface { } ) if val , ok := data [ " " ] ; ! ok || ( ok && ( f . id != val ) ) { continue } switch ev . Type { case events . FolderSummary : log . WithFields ( f . ShortFields ( ) ) . Info ( " " ) f . Status = ServiceUpdating case events . FolderCompletion : log . WithFields ( f . ShortFields ( ) ) . Info ( " " ) f . Status = ServiceWatching if f . Reload { f . restartContainer <- true } } } log . WithFields ( f . Fields ( ) ) . Debug ( " " ) } ( ) return nil }
Pay attention to the events coming off the local syncthing server to update
state and reload the remote container if required.
Pay attention to the events coming off the local syncthing server to update state and reload the remote container if required .