forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
52 lines (43 loc) · 1.27 KB
/
config.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package pipeline
import (
"errors"
"fmt"
"time"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/publisher/beat"
)
// Config object for loading a pipeline instance via Load.
type Config struct {
WaitShutdown time.Duration `config:"wait_shutdown"`
Broker common.ConfigNamespace `config:"broker"`
Output common.ConfigNamespace `config:"output"`
}
// validateClientConfig checks a ClientConfig can be used with (*Pipeline).ConnectWith.
func validateClientConfig(c *beat.ClientConfig) error {
withDrop := false
switch m := c.PublishMode; m {
case beat.DefaultGuarantees, beat.GuaranteedSend:
case beat.DropIfFull:
withDrop = true
default:
return fmt.Errorf("unknown publishe mode %v", m)
}
fnCount := 0
countPtr := func(b bool) {
if b {
fnCount++
}
}
countPtr(c.ACKCount != nil)
countPtr(c.ACKEvents != nil)
countPtr(c.ACKLastEvent != nil)
if fnCount > 1 {
return fmt.Errorf("At most one of ACKCount, ACKEvents, ACKLastEvent can be configured")
}
// ACK handlers can not be registered DropIfFull is set, as dropping events
// due to full broker can not be accounted for in the clients acker.
if fnCount != 0 && withDrop {
return errors.New("ACK handlers with DropIfFull mode not supported")
}
return nil
}