-
Notifications
You must be signed in to change notification settings - Fork 5k
feat: replace custom atomic with sync/atomic #40132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Go 1.19 added new atomic types. Replace custom atomic types with stdlib atomic package to fully use the race detector, improved lsp hints and support. Use pointers in sniffer struct to prevent copying the atomic struct and cause a race condition.
|
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
fix golangci-lint issue
This doesn't look like an issue with this PR 🤔 Is it intended ? |
| _serverRequestCount atomic.Int64 // Requests directly to the server | ||
| _proxyRequestCount atomic.Int64 // Requests via the proxy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original is 32 bits wide. Do we care? There is almost no-one in the world who that would affect, and it would have affected them anyway. Raising only for awareness.
| config config.InterfaceConfig | ||
|
|
||
| state atomic.Int32 // store snifferState | ||
| state *atomic.Int32 // store snifferState |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than making this a pointer, the child could be directly assigned to sniffers[i] at L105 and child be made a *sniffer from sniffers[i] for ergonomics immediately after. Your choice.
Co-authored-by: Dan Kortschak <[email protected]>
fix golangci-lint issue
We can just Apache license the package most likely and move it out of x-pack (or get rid of our use of this entirely). |
|
@pkoutsovasilis Here's an issue for that. #40293 |
leehinman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question on removal of closeOnce, otherwise I'm OK with this.
This PR is blocked by the linter failure, as reported in this issue: There's a PR up to fix that issue: @leehinman perhaps you could take a look at that PR to unblock this one? |
|
#40483 has now been merged, so this PR here should now be unblocked. |
|
|
|
@elastic/obs-infraobs-integrations @elastic/obs-ds-hosted-services @elastic/obs-cloud-monitoring @elastic/sec-windows-platform friendly ping for review |
andrewkroh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving changes to winlogbeat/* on behalf of sec-windows-platform.
|
@elastic/obs-cloud-monitoring @elastic/obs-ds-hosted-services friendly ping 🙂 |
vigneshshanmugam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kruskall Heartbeat changes LGTM
* feat: replace custom atomic with sync/atomic Go 1.19 added new atomic types. Replace custom atomic types with stdlib atomic package to fully use the race detector, improved lsp hints and support. Use pointers in sniffer struct to prevent copying the atomic struct and cause a race condition. * lint: time.Now().Sub -> time.Since fix golangci-lint issue * Apply suggestions from code review Co-authored-by: Dan Kortschak <[email protected]> * refactor: keep Swap usage as is * lint: avoid unnecessary conversion fix golangci-lint issue * fix: update method reference to new atomic types * fix: resolve more compile errors and test failures * lint: fix linter issues * lint: fix linter issues * lint: fix linter issues * lint: fix linter issues * lint: more linting errors * lint: fix linter issues * lint: remove unused import * lint: fix linter issue * lint: fix linter issues * lint: fix linter issues --------- Co-authored-by: Dan Kortschak <[email protected]> (cherry picked from commit 296b83b) # Conflicts: # filebeat/inputsource/common/streaming/listener.go
* feat: replace custom atomic with sync/atomic Go 1.19 added new atomic types. Replace custom atomic types with stdlib atomic package to fully use the race detector, improved lsp hints and support. Use pointers in sniffer struct to prevent copying the atomic struct and cause a race condition. * lint: time.Now().Sub -> time.Since fix golangci-lint issue * Apply suggestions from code review Co-authored-by: Dan Kortschak <[email protected]> * refactor: keep Swap usage as is * lint: avoid unnecessary conversion fix golangci-lint issue * fix: update method reference to new atomic types * fix: resolve more compile errors and test failures * lint: fix linter issues * lint: fix linter issues * lint: fix linter issues * lint: fix linter issues * lint: more linting errors * lint: fix linter issues * lint: remove unused import * lint: fix linter issue * lint: fix linter issues * lint: fix linter issues --------- Co-authored-by: Dan Kortschak <[email protected]>
…41979) * feat: replace custom atomic with sync/atomic (#40132) * feat: replace custom atomic with sync/atomic Go 1.19 added new atomic types. Replace custom atomic types with stdlib atomic package to fully use the race detector, improved lsp hints and support. Use pointers in sniffer struct to prevent copying the atomic struct and cause a race condition. * lint: time.Now().Sub -> time.Since fix golangci-lint issue * Apply suggestions from code review Co-authored-by: Dan Kortschak <[email protected]> * refactor: keep Swap usage as is * lint: avoid unnecessary conversion fix golangci-lint issue * fix: update method reference to new atomic types * fix: resolve more compile errors and test failures * lint: fix linter issues * lint: fix linter issues * lint: fix linter issues * lint: fix linter issues * lint: more linting errors * lint: fix linter issues * lint: remove unused import * lint: fix linter issue * lint: fix linter issues * lint: fix linter issues --------- Co-authored-by: Dan Kortschak <[email protected]> (cherry picked from commit 296b83b) # Conflicts: # filebeat/inputsource/common/streaming/listener.go * Update listener.go --------- Co-authored-by: kruskall <[email protected]>
Proposed commit message
Go 1.19 added new atomic types. Replace custom atomic types with stdlib atomic package to fully use the race detector, improved lsp hints and support.
Use pointers in sniffer struct to prevent copying the atomic struct and cause a race condition.
Checklist
CHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Disruptive User Impact
Author's Checklist
How to test this PR locally
Related issues
Use cases
Screenshots
Logs