-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore][pkg/stanza] Cleanup namedpipe input operator files (#32075)
Contributes to #32058
- Loading branch information
1 parent
12fe8e2
commit eb308a9
Showing
5 changed files
with
81 additions
and
67 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build linux | ||
|
||
package namedpipe // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/namedpipe" | ||
|
||
import ( | ||
"fmt" | ||
|
||
"go.uber.org/zap" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/decode" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator" | ||
) | ||
|
||
func init() { | ||
operator.Register(operatorType, func() operator.Builder { return NewConfig() }) | ||
} | ||
|
||
// Build will build a namedpipe input operator. | ||
func (c *Config) Build(logger *zap.SugaredLogger) (operator.Operator, error) { | ||
inputOperator, err := c.InputConfig.Build(logger) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
enc, err := decode.LookupEncoding(c.Encoding) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to lookup encoding %q: %w", c.Encoding, err) | ||
} | ||
|
||
splitFunc, err := c.SplitConfig.Func(enc, true, DefaultMaxLogSize) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create split function: %w", err) | ||
} | ||
|
||
maxLogSize := c.MaxLogSize | ||
if maxLogSize == 0 { | ||
maxLogSize = DefaultMaxLogSize | ||
} | ||
|
||
return &Input{ | ||
InputOperator: inputOperator, | ||
|
||
buffer: make([]byte, maxLogSize), | ||
path: c.Path, | ||
permissions: c.Permissions, | ||
splitFunc: splitFunc, | ||
trimFunc: c.TrimConfig.Func(), | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.