Skip to content

Commit

Permalink
Port data race problem fix (#284)
Browse files Browse the repository at this point in the history
* Port data race problem fix
  • Loading branch information
Mrod1598 authored May 7, 2021
1 parent d62ea9b commit 749c6cc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added Azure Log Analytics Operator [PR 287](https://github.com/observIQ/stanza/pull/287)

## [0.13.19] - 2021-04-15

### Added
- Added float64 to Severity parser's supported types [PR 267](https://github.com/observIQ/stanza/issues/267)

Expand Down
5 changes: 1 addition & 4 deletions operator/builtin/parser/syslog/syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ type SyslogParser struct {

// Process will parse an entry field as syslog.
func (s *SyslogParser) Process(ctx context.Context, entry *entry.Entry) error {
if err := s.ParserOperator.ProcessWith(ctx, entry, s.parse); err != nil {
return err
}
return promoteSeverity(entry)
return s.ParserOperator.ProcessWithCallback(ctx, entry, s.parse, promoteSeverity)
}

// parse will parse a value as syslog.
Expand Down
11 changes: 11 additions & 0 deletions operator/helper/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ type ParserOperator struct {

// ProcessWith will run ParseWith on the entry, then forward the entry on to the next operators.
func (p *ParserOperator) ProcessWith(ctx context.Context, entry *entry.Entry, parse ParseFunction) error {
return p.ProcessWithCallback(ctx, entry, parse, nil)
}

func (p *ParserOperator) ProcessWithCallback(ctx context.Context, entry *entry.Entry, parse ParseFunction, cb func(*entry.Entry) error) error {
// Short circuit if the "if" condition does not match
skip, err := p.Skip(ctx, entry)
if err != nil {
Expand All @@ -86,6 +90,13 @@ func (p *ParserOperator) ProcessWith(ctx context.Context, entry *entry.Entry, pa
if err := p.ParseWith(ctx, entry, parse); err != nil {
return err
}
if cb != nil {
err = cb(entry)
if err != nil {
return err
}
}

p.Write(ctx, entry)
return nil
}
Expand Down

0 comments on commit 749c6cc

Please sign in to comment.