Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small pipeline enhancements #12996

Merged
merged 3 commits into from
Jul 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ The list below covers the major changes between 7.0.0-rc2 and master only.
- New ReporterV2 interfaces that can receive a context on `Fetch(ctx, reporter)`, or `Run(ctx, reporter)`. {pull}11981[11981]
- Generate configuration from `mage` for all Beats. {pull}12618[12618]
- Add ClientFactory to TCP input source to add SplitFunc/NetworkFuncs per client. {pull}8543[8543]
- Introduce beat.OutputChooses publisher mode. {pull}12996[12996]
- Ensure that beat.Processor, beat.ProcessorList, and processors.ProcessorList are compatible and can be composed more easily. {pull}12996[12996]
11 changes: 9 additions & 2 deletions libbeat/beat/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ type PipelineACKHandler struct {
}

type ProcessorList interface {
Processor
All() []Processor
}

Expand All @@ -144,10 +145,16 @@ type Processor interface {
type PublishMode uint8

const (
// DefaultGuarantees are up to the pipeline configuration, as configured by the
// operator.
// DefaultGuarantees are up to the pipeline configuration itself.
DefaultGuarantees PublishMode = iota

// OutputChooses mode fully depends on the output and its configuration.
// Events might be dropped based on the users output configuration.
// In this mode no events are dropped within the pipeline. Events are only removed
// after the output has ACKed the events to the pipeline, even if the output
// did drop the events.
OutputChooses

// GuaranteedSend ensures events are retried until acknowledged by the output.
// Normally guaranteed sending should be used with some client ACK-handling
// to update state keeping track of the sending status.
Expand Down
14 changes: 11 additions & 3 deletions libbeat/processors/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,18 @@ type Processor interface {
String() string
}

func New(config PluginConfig) (*Processors, error) {
procs := &Processors{
log: logp.NewLogger(logName),
// NewList creates a new empty processor list.
// Additional processors can be added to the List field.
func NewList(log *logp.Logger) *Processors {
urso marked this conversation as resolved.
Show resolved Hide resolved
if log == nil {
log = logp.NewLogger(logName)
}
return &Processors{log: log}
}

// New creates a list of processors from a list of free user configurations.
func New(config PluginConfig) (*Processors, error) {
urso marked this conversation as resolved.
Show resolved Hide resolved
procs := NewList(nil)

for _, procConfig := range config {
// Handle if/then/else processor which has multiple top-level keys.
Expand Down
2 changes: 1 addition & 1 deletion libbeat/publisher/pipeline/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func validateClientConfig(c *beat.ClientConfig) error {
withDrop := false

switch m := c.PublishMode; m {
case beat.DefaultGuarantees, beat.GuaranteedSend:
case beat.DefaultGuarantees, beat.GuaranteedSend, beat.OutputChooses:
case beat.DropIfFull:
withDrop = true
default:
Expand Down
6 changes: 5 additions & 1 deletion libbeat/publisher/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ import (
// the output clients using a shared work queue for the active outputs.Group.
// Processors in the pipeline are executed in the clients go-routine, before
// entering the queue. No filtering/processing will occur on the output side.
//
// For client connecting to this pipeline, the default PublishMode is
// OutputChooses.
type Pipeline struct {
beatInfo beat.Info

Expand Down Expand Up @@ -273,14 +276,15 @@ func (p *Pipeline) Close() error {
return nil
}

// Connect creates a new client with default settings
// Connect creates a new client with default settings.
func (p *Pipeline) Connect() (beat.Client, error) {
return p.ConnectWith(beat.ClientConfig{})
}

// ConnectWith create a new Client for publishing events to the pipeline.
// The client behavior on close and ACK handling can be configured by setting
// the appropriate fields in the passed ClientConfig.
// If not set otherwise the defaut publish mode is OutputChooses.
func (p *Pipeline) ConnectWith(cfg beat.ClientConfig) (beat.Client, error) {
var (
canDrop bool
Expand Down