Call monitor via callback in server
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user