forked from src-d/lookout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
poster.go
38 lines (31 loc) · 1.1 KB
/
poster.go
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
30
31
32
33
34
35
36
37
38
package lookout
import "context"
// AnalysisStatus is the status reported to the provider to
// inform that we are performing an analysis, or that it has finished
type AnalysisStatus int
const (
_ AnalysisStatus = iota
// ErrorAnalysisStatus represents an error status
ErrorAnalysisStatus
// FailureAnalysisStatus represents a failure status
FailureAnalysisStatus
// PendingAnalysisStatus represents a pending status
PendingAnalysisStatus
// SuccessAnalysisStatus represents a success status
SuccessAnalysisStatus
)
func (st AnalysisStatus) String() string {
names := [...]string{"unknown", "error", "failure", "pending", "success"}
if st < ErrorAnalysisStatus || st > SuccessAnalysisStatus {
return names[0]
}
return names[st]
}
// Poster can post comments about an event.
type Poster interface {
// Post posts comments about an event.
// poster should make sure comments weren't posted before if safe is true
Post(ctx context.Context, e Event, cs []AnalyzerComments, safe bool) error
// Status sends the current analysis status to the provider
Status(context.Context, Event, AnalysisStatus) error
}