Skip to content

Commit 15ab4ad

Browse files
committed
Additional cleanup relating to multiline rename
1 parent 984e850 commit 15ab4ad

File tree

13 files changed

+57
-32
lines changed

13 files changed

+57
-32
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: pkg/stanza
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Rename syslog and tcp MultilineBuilders
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [26631]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: |
19+
- Rename syslog.OctetMultiLineBuilder to syslog.OctetSplitFuncBuilder
20+
- Rename tc.MultilineBuilder to tcp.SplitFuncBuilder
21+
22+
# If your change doesn't affect end users or the exported elements of any package,
23+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
24+
# Optional: The change log or logs in which this entry should be included.
25+
# e.g. '[user]' or '[user, api]'
26+
# Include 'user' if the change is relevant to end users.
27+
# Include 'api' if there is a change to a library API.
28+
# Default: '[user]'
29+
change_logs: [api]

pkg/stanza/fileconsumer/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (c Config) Build(logger *zap.SugaredLogger, emit emit.Callback) (*Manager,
101101

102102
// Ensure that splitter is buildable
103103
factory := splitter.NewSplitFuncFactory(c.SplitConfig, enc, int(c.MaxLogSize), c.TrimConfig.Func(), c.FlushPeriod)
104-
if _, err := factory.Build(); err != nil {
104+
if _, err := factory.SplitFunc(); err != nil {
105105
return nil, err
106106
}
107107

@@ -120,7 +120,7 @@ func (c Config) BuildWithSplitFunc(logger *zap.SugaredLogger, emit emit.Callback
120120

121121
// Ensure that splitter is buildable
122122
factory := splitter.NewCustomFactory(splitFunc, c.FlushPeriod)
123-
if _, err := factory.Build(); err != nil {
123+
if _, err := factory.SplitFunc(); err != nil {
124124
return nil, err
125125
}
126126

pkg/stanza/fileconsumer/internal/splitter/custom.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func NewCustomFactory(splitFunc bufio.SplitFunc, flushPeriod time.Duration) Fact
2525
}
2626
}
2727

28-
// Build builds Multiline Splitter struct
29-
func (f *customFactory) Build() (bufio.SplitFunc, error) {
28+
// SplitFunc builds a bufio.SplitFunc based on the configuration
29+
func (f *customFactory) SplitFunc() (bufio.SplitFunc, error) {
3030
return flush.WithPeriod(f.splitFunc, trim.Nop, f.flushPeriod), nil
3131
}

pkg/stanza/fileconsumer/internal/splitter/custom_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestCustomFactory(t *testing.T) {
3030
for _, tt := range tests {
3131
t.Run(tt.name, func(t *testing.T) {
3232
factory := NewCustomFactory(tt.splitter, tt.flushPeriod)
33-
got, err := factory.Build()
33+
got, err := factory.SplitFunc()
3434
if (err != nil) != tt.wantErr {
3535
t.Errorf("Build() error = %v, wantErr %v", err, tt.wantErr)
3636
return

pkg/stanza/fileconsumer/internal/splitter/factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ import (
88
)
99

1010
type Factory interface {
11-
Build() (bufio.SplitFunc, error)
11+
SplitFunc() (bufio.SplitFunc, error)
1212
}

pkg/stanza/fileconsumer/internal/splitter/multiline.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ func NewSplitFuncFactory(
4040
}
4141
}
4242

43-
// Build builds Multiline Splitter struct
44-
func (f *splitFuncFactory) Build() (bufio.SplitFunc, error) {
43+
// SplitFunc builds a bufio.SplitFunc based on the configuration
44+
func (f *splitFuncFactory) SplitFunc() (bufio.SplitFunc, error) {
4545
splitFunc, err := f.splitConfig.Func(f.encoding, false, f.maxLogSize, f.trimFunc)
4646
if err != nil {
4747
return nil, err

pkg/stanza/fileconsumer/internal/splitter/multiline_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
func TestSplitFuncFactory(t *testing.T) {
1919
tests := []struct {
2020
name string
21-
splitFunc split.Config
21+
splitConfig split.Config
2222
encoding encoding.Encoding
2323
maxLogSize int
2424
flushPeriod time.Duration
@@ -32,8 +32,8 @@ func TestSplitFuncFactory(t *testing.T) {
3232
wantErr: false,
3333
},
3434
{
35-
name: "Multiline error",
36-
splitFunc: split.Config{
35+
name: "split config error",
36+
splitConfig: split.Config{
3737
LineStartPattern: "START",
3838
LineEndPattern: "END",
3939
},
@@ -45,10 +45,10 @@ func TestSplitFuncFactory(t *testing.T) {
4545
}
4646
for _, tt := range tests {
4747
t.Run(tt.name, func(t *testing.T) {
48-
factory := NewSplitFuncFactory(tt.splitFunc, tt.encoding, tt.maxLogSize, trim.Nop, tt.flushPeriod)
49-
got, err := factory.Build()
48+
factory := NewSplitFuncFactory(tt.splitConfig, tt.encoding, tt.maxLogSize, trim.Nop, tt.flushPeriod)
49+
got, err := factory.SplitFunc()
5050
if (err != nil) != tt.wantErr {
51-
t.Errorf("Build() error = %v, wantErr %v", err, tt.wantErr)
51+
t.Errorf("SplitFunc() error = %v, wantErr %v", err, tt.wantErr)
5252
return
5353
}
5454
if err == nil {

pkg/stanza/fileconsumer/reader_factory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type readerFactory struct {
2929
}
3030

3131
func (f *readerFactory) newReader(file *os.File, fp *fingerprint.Fingerprint) (*reader, error) {
32-
lineSplitFunc, err := f.splitterFactory.Build()
32+
lineSplitFunc, err := f.splitterFactory.SplitFunc()
3333
if err != nil {
3434
return nil, err
3535
}
@@ -44,7 +44,7 @@ func (f *readerFactory) copy(old *reader, newFile *os.File) (*reader, error) {
4444
var err error
4545
lineSplitFunc := old.lineSplitFunc
4646
if lineSplitFunc == nil {
47-
lineSplitFunc, err = f.splitterFactory.Build()
47+
lineSplitFunc, err = f.splitterFactory.SplitFunc()
4848
if err != nil {
4949
return nil, err
5050
}

pkg/stanza/fileconsumer/reader_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ func TestHeaderFingerprintIncluded(t *testing.T) {
226226
func testReaderFactory(t *testing.T, sCfg split.Config, maxLogSize int, flushPeriod time.Duration) (*readerFactory, chan *emitParams) {
227227
emitChan := make(chan *emitParams, 100)
228228
enc, err := decode.LookupEncoding(defaultEncoding)
229-
trimFunc := trim.Whitespace
230229
require.NoError(t, err)
231230
return &readerFactory{
232231
SugaredLogger: testutil.Logger(t),
@@ -236,7 +235,7 @@ func testReaderFactory(t *testing.T, sCfg split.Config, maxLogSize int, flushPer
236235
emit: testEmitFunc(emitChan),
237236
},
238237
fromBeginning: true,
239-
splitterFactory: splitter.NewSplitFuncFactory(sCfg, enc, maxLogSize, trimFunc, flushPeriod),
238+
splitterFactory: splitter.NewSplitFuncFactory(sCfg, enc, maxLogSize, trim.Whitespace, flushPeriod),
240239
encoding: enc,
241240
}, emitChan
242241
}

pkg/stanza/operator/input/syslog/syslog.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (c Config) Build(logger *zap.SugaredLogger) (operator.Operator, error) {
6464
tcpInputCfg := tcp.NewConfigWithID(inputBase.ID() + "_internal_tcp")
6565
tcpInputCfg.BaseConfig = *c.TCP
6666
if syslogParserCfg.EnableOctetCounting {
67-
tcpInputCfg.MultiLineBuilder = OctetMultiLineBuilder
67+
tcpInputCfg.SplitFuncBuilder = OctetSplitFuncBuilder
6868
}
6969

7070
tcpInput, err := tcpInputCfg.Build(logger)
@@ -144,7 +144,7 @@ func (t *Input) SetOutputs(operators []operator.Operator) error {
144144
return t.parser.SetOutputs(operators)
145145
}
146146

147-
func OctetMultiLineBuilder(_ encoding.Encoding) (bufio.SplitFunc, error) {
147+
func OctetSplitFuncBuilder(_ encoding.Encoding) (bufio.SplitFunc, error) {
148148
return newOctetFrameSplitFunc(true), nil
149149
}
150150

0 commit comments

Comments
 (0)