func (this *Ext) Collect() { for { now := time.Now() timeDelta := now.Sub(this.timestamp) timeCondition := (this.timestamp.Before(now) && timeDelta > this.period) if timeCondition || this.init { this.init = false logging.Info(fmt.Sprintf("GET %s", this.url)) resp, err := http.Get(this.url) if err != nil { logging.Error(err) return } payload, err := ioutil.ReadAll(resp.Body) if err != nil { logging.Error(err) return } this.dataCh <- payload } select { case <-time.After(this.period): continue case <-this.quitCh: return } } }
func (this *Manager) logAccess(r *http.Request) { logging.Info(fmt.Sprintf("%s accessed by %s", r.URL, r.RemoteAddr)) }