Skip to content

Commit

Permalink
Avoid brokers when unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffail committed Jan 17, 2018
1 parent 27fde7d commit fe7ab2f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/input/fan_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ func NewFanIn(
return nil, err
}

if len(inputConfs) == 0 {
return nil, ErrFanInNoInputs
} else if len(inputConfs) == 1 {
return New(inputConfs[0], log, stats, pipelines...)
}

inputs := make([]types.Producer, len(inputConfs))

for i, iConf := range inputConfs {
Expand Down
6 changes: 6 additions & 0 deletions lib/output/fan_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ func NewFanOut(conf Config, log log.Modular, stats metrics.Type) (Type, error) {
return nil, err
}

if len(outputConfs) == 0 {
return nil, ErrFanOutNoOutputs
} else if len(outputConfs) == 1 {
return New(outputConfs[0], log, stats)
}

outputs := make([]types.Consumer, len(outputConfs))

for i, oConf := range outputConfs {
Expand Down
6 changes: 6 additions & 0 deletions lib/output/round_robin.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ func NewRoundRobin(conf Config, log log.Modular, stats metrics.Type) (Type, erro
return nil, err
}

if len(outputConfs) == 0 {
return nil, ErrFanOutNoOutputs
} else if len(outputConfs) == 1 {
return New(outputConfs[0], log, stats)
}

outputs := make([]types.Consumer, len(outputConfs))

for i, oConf := range outputConfs {
Expand Down

0 comments on commit fe7ab2f

Please sign in to comment.