Exemplo n.º 1
0
func (w *Watcher) SetLowerInterval(intervalStr string) {
	interval, err := intervals.GetByValue(intervalStr).One()
	if err != nil {
		interval, err = intervals.New(intervalStr)
		if err != nil {
			return
		}
	}
	// BUG(setLowerInterval) implement this, make it sort intervals perhaps using the cache
	// and set the watcher to use the smaller interval
	fmt.Println("%s", interval.Value)
}
Exemplo n.º 2
0
func New(d domains.Domain, interval string) (Watcher, error) {
	w := Watcher{}
	w.Domain = d
	i, err := intervals.New(interval)
	if err != nil {
		// TODO: better wrapper for our db errors so can see in log which package
		return w, err
	}
	w.Interval = i
	w.Updated = time.Now()
	w.Added = time.Now()
	conn, err := connection.Get()
	if err != nil {
		return w, err
	}
	err = conn.QueryRow("INSERT INTO watcher (domain, interval) VALUES ($1, $2) RETURNING id",
		d.UUID.String(),
		i.ID,
	).Scan(&w.ID)
	if err != nil {
		return w, err
	}
	return GetByDomain(d).One()
}