forked from reviewdog/reviewdog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomment.go
37 lines (31 loc) · 861 Bytes
/
comment.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
package reviewdog
import "context"
var _ BulkCommentService = &multiCommentService{}
type multiCommentService struct {
services []CommentService
}
func (m *multiCommentService) Post(ctx context.Context, c *Comment) error {
for _, cs := range m.services {
if err := cs.Post(ctx, c); err != nil {
return err
}
}
return nil
}
func (m *multiCommentService) Flush(ctx context.Context) error {
for _, cs := range m.services {
if bulk, ok := cs.(BulkCommentService); ok {
if err := bulk.Flush(ctx); err != nil {
return err
}
}
}
return nil
}
// MultiCommentService creates a comment service that duplicates its post to
// all the provided comment services.
func MultiCommentService(services ...CommentService) CommentService {
s := make([]CommentService, len(services))
copy(s, services)
return &multiCommentService{services: s}
}