Skip to content

Commit

Permalink
[chore][pkg/stanza] Rename internal function name
Browse files Browse the repository at this point in the history
  • Loading branch information
djaglowski committed Sep 11, 2023
1 parent ca8c1ad commit 984e850
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion pkg/stanza/fileconsumer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (c Config) Build(logger *zap.SugaredLogger, emit emit.Callback) (*Manager,
}

// Ensure that splitter is buildable
factory := splitter.NewMultilineFactory(c.SplitConfig, enc, int(c.MaxLogSize), c.TrimConfig.Func(), c.FlushPeriod)
factory := splitter.NewSplitFuncFactory(c.SplitConfig, enc, int(c.MaxLogSize), c.TrimConfig.Func(), c.FlushPeriod)
if _, err := factory.Build(); err != nil {
return nil, err
}
Expand Down
34 changes: 17 additions & 17 deletions pkg/stanza/fileconsumer/internal/splitter/multiline.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,35 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/trim"
)

type multilineFactory struct {
multilineCfg split.Config
encoding encoding.Encoding
maxLogSize int
trimFunc trim.Func
flushPeriod time.Duration
type splitFuncFactory struct {
splitConfig split.Config
encoding encoding.Encoding
maxLogSize int
trimFunc trim.Func
flushPeriod time.Duration
}

var _ Factory = (*multilineFactory)(nil)
var _ Factory = (*splitFuncFactory)(nil)

func NewMultilineFactory(
multilineCfg split.Config,
func NewSplitFuncFactory(
splitConfig split.Config,
encoding encoding.Encoding,
maxLogSize int,
trimFunc trim.Func,
flushPeriod time.Duration,
) Factory {
return &multilineFactory{
multilineCfg: multilineCfg,
encoding: encoding,
maxLogSize: maxLogSize,
trimFunc: trimFunc,
flushPeriod: flushPeriod,
return &splitFuncFactory{
splitConfig: splitConfig,
encoding: encoding,
maxLogSize: maxLogSize,
trimFunc: trimFunc,
flushPeriod: flushPeriod,
}
}

// Build builds Multiline Splitter struct
func (f *multilineFactory) Build() (bufio.SplitFunc, error) {
splitFunc, err := f.multilineCfg.Func(f.encoding, false, f.maxLogSize, f.trimFunc)
func (f *splitFuncFactory) Build() (bufio.SplitFunc, error) {
splitFunc, err := f.splitConfig.Func(f.encoding, false, f.maxLogSize, f.trimFunc)
if err != nil {
return nil, err
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/stanza/fileconsumer/internal/splitter/multiline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/trim"
)

func TestMultilineBuild(t *testing.T) {
func TestSplitFuncFactory(t *testing.T) {
tests := []struct {
name string
multilineCfg split.Config
encoding encoding.Encoding
maxLogSize int
flushPeriod time.Duration
wantErr bool
name string
splitFunc split.Config
encoding encoding.Encoding
maxLogSize int
flushPeriod time.Duration
wantErr bool
}{
{
name: "default configuration",
Expand All @@ -33,7 +33,7 @@ func TestMultilineBuild(t *testing.T) {
},
{
name: "Multiline error",
multilineCfg: split.Config{
splitFunc: split.Config{
LineStartPattern: "START",
LineEndPattern: "END",
},
Expand All @@ -45,7 +45,7 @@ func TestMultilineBuild(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
factory := NewMultilineFactory(tt.multilineCfg, tt.encoding, tt.maxLogSize, trim.Nop, tt.flushPeriod)
factory := NewSplitFuncFactory(tt.splitFunc, tt.encoding, tt.maxLogSize, trim.Nop, tt.flushPeriod)
got, err := factory.Build()
if (err != nil) != tt.wantErr {
t.Errorf("Build() error = %v, wantErr %v", err, tt.wantErr)
Expand Down
2 changes: 1 addition & 1 deletion pkg/stanza/fileconsumer/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func testReaderFactory(t *testing.T, sCfg split.Config, maxLogSize int, flushPer
emit: testEmitFunc(emitChan),
},
fromBeginning: true,
splitterFactory: splitter.NewMultilineFactory(sCfg, enc, maxLogSize, trimFunc, flushPeriod),
splitterFactory: splitter.NewSplitFuncFactory(sCfg, enc, maxLogSize, trimFunc, flushPeriod),
encoding: enc,
}, emitChan
}
Expand Down

0 comments on commit 984e850

Please sign in to comment.