Skip to content

Commit 62576ea

Browse files
authored
[chore] Remove usage of pointers for state in metadata (#37784)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> Signed-off-by: Bogdan Drutu <[email protected]>
1 parent 9b05daf commit 62576ea

File tree

5 files changed

+33
-19
lines changed

5 files changed

+33
-19
lines changed

.chloggen/not-sure-understand.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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: Remove deprecated `flush.WithPeriod`.
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: [37784]
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+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [api]

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,15 @@ func (f *Factory) NewReader(file *os.File, fp *fingerprint.Fingerprint) (*Reader
5959
m := &Metadata{
6060
Fingerprint: fp,
6161
FileAttributes: attributes,
62-
TokenLenState: &tokenlen.State{},
63-
}
64-
if f.FlushTimeout > 0 {
65-
m.FlushState = &flush.State{LastDataChange: time.Now()}
62+
TokenLenState: tokenlen.State{},
63+
FlushState: flush.State{
64+
LastDataChange: time.Now(),
65+
},
6666
}
6767
return f.NewReaderFromMetadata(file, m)
6868
}
6969

7070
func (f *Factory) NewReaderFromMetadata(file *os.File, m *Metadata) (r *Reader, err error) {
71-
// Ensure TokenLenState is initialized
72-
if m.TokenLenState == nil {
73-
m.TokenLenState = &tokenlen.State{}
74-
}
75-
7671
r = &Reader{
7772
Metadata: m,
7873
set: f.TelemetrySettings,

pkg/stanza/fileconsumer/internal/reader/reader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ type Metadata struct {
3131
RecordNum int64
3232
FileAttributes map[string]any
3333
HeaderFinalized bool
34-
FlushState *flush.State
35-
TokenLenState *tokenlen.State
34+
FlushState flush.State
35+
TokenLenState tokenlen.State
3636
}
3737

3838
// Reader manages a single file

pkg/stanza/flush/flush.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,3 @@ func (s *State) Func(splitFunc bufio.SplitFunc, period time.Duration) bufio.Spli
6161
return 0, nil, nil
6262
}
6363
}
64-
65-
// Deprecated: [v0.88.0] Use WithFunc instead.
66-
func WithPeriod(splitFunc bufio.SplitFunc, period time.Duration) bufio.SplitFunc {
67-
s := &State{LastDataChange: internaltime.Now()}
68-
return s.Func(splitFunc, period)
69-
}

pkg/stanza/flush/flush_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ func TestNewlineSplitFunc(t *testing.T) {
4141
}
4242

4343
for _, tc := range testCases {
44-
t.Run(tc.name+"/WithPeriod", splittest.New(WithPeriod(tc.baseFunc, tc.flushPeriod), tc.input, tc.steps...))
45-
4644
previousState := &State{LastDataChange: time.Now()}
4745
t.Run(tc.name+"/Func", splittest.New(previousState.Func(tc.baseFunc, tc.flushPeriod), tc.input, tc.steps...))
4846
}

0 commit comments

Comments
 (0)