-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathoutput.go
More file actions
60 lines (49 loc) · 1.57 KB
/
output.go
File metadata and controls
60 lines (49 loc) · 1.57 KB
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
53
54
55
56
57
58
59
60
package helper
import (
"github.com/observiq/stanza/errors"
"github.com/observiq/stanza/operator"
)
// NewOutputConfig creates a new output config
func NewOutputConfig(operatorID, operatorType string) OutputConfig {
return OutputConfig{
BasicConfig: NewBasicConfig(operatorID, operatorType),
}
}
// OutputConfig provides a basic implementation of an output operator config.
type OutputConfig struct {
BasicConfig `mapstructure:",squash" yaml:",inline"`
}
// Build will build an output operator.
func (c OutputConfig) Build(context operator.BuildContext) (OutputOperator, error) {
basicOperator, err := c.BasicConfig.Build(context)
if err != nil {
return OutputOperator{}, err
}
outputOperator := OutputOperator{
BasicOperator: basicOperator,
}
return outputOperator, nil
}
// OutputOperator provides a basic implementation of an output operator.
type OutputOperator struct {
BasicOperator
}
// CanProcess will always return true for an output operator.
func (o *OutputOperator) CanProcess() bool {
return true
}
// CanOutput will always return false for an output operator.
func (o *OutputOperator) CanOutput() bool {
return false
}
// Outputs will always return an empty array for an output operator.
func (o *OutputOperator) Outputs() []operator.Operator {
return []operator.Operator{}
}
// SetOutputs will return an error if called.
func (o *OutputOperator) SetOutputs(operators []operator.Operator) error {
return errors.NewError(
"Operator can not output, but is attempting to set an output.",
"This is an unexpected internal error. Please submit a bug/issue.",
)
}