-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathwatcher.go
More file actions
29 lines (23 loc) · 818 Bytes
/
watcher.go
File metadata and controls
29 lines (23 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package lookout
import (
"context"
"gopkg.in/src-d/go-errors.v1"
)
var (
// NoErrStopWatcher if a new error of this kind is returned by EventHandler
// the Watcher.Watch function exits without error.
NoErrStopWatcher = errors.NewKind("Stop watcher")
)
// Watcher watch for new events in given provider.
type Watcher interface {
// Watch for new events triggering the EventHandler for each new issue,
// it stops until an error is returned by the EventHandler. Network errors
// or other temporal errors are handled as non-fatal errors, just logging it.
Watch(context.Context, EventHandler) error
}
// EventHandler funciton to be called when a new event happends.
type EventHandler func(Event) error
// WatchOptions options to use in the Watcher constructors.
type WatchOptions struct {
URLs []string
}