Call monitor via callback in server

This commit is contained in:
Bel LaPointe
2018-10-09 08:28:57 -06:00
parent 772058abbc
commit 8f5630353e
4 changed files with 32 additions and 11 deletions

View File

@@ -23,6 +23,18 @@ func New(port string, trigger func(string)) (*Monitor, error) {
}, nil
}
func (monitor *Monitor) Submit(url string, interval time.Duration) error {
select {
case monitor.newItems <- Item{
URL: url,
Interval: Duration{interval},
}:
case <-time.After(time.Second * 5):
return errors.New("timeout submitting new item")
}
return nil
}
func (monitor *Monitor) Start() error {
errs := make(chan error)
go func() {