Skip to content
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

Use sync/atomic, drop external atomics #1253

Merged
merged 1 commit into from
Mar 19, 2023
Merged

Use sync/atomic, drop external atomics #1253

merged 1 commit into from
Mar 19, 2023

Conversation

abhinav
Copy link
Collaborator

@abhinav abhinav commented Mar 19, 2023

Switches all uses of go.uber.org/atomic to types defined in sync/atomic.
These types have been available since Go 1.19,
which is the minimum supported version of Go for Zap.

This allows us to drop one dependency from Zap.
The version of multierr was bumped to pick up uber-go/multierr#72
which made a similar change to that package.

This was nearly a drop-in, save the following:

  • There's no Int*.Inc; we have to use Int*.Add(1)
  • There's no Bool.Toggle; we have to implement the CAS loop manually

This change has no user-facing consequences
because nearly all atomic usages are internal to Zap.
The only atomic exposed (AtomicLevel) is a wrapper type
for which the behavior does not change.

Switches all uses of go.uber.org/atomic to types defined in sync/atomic.
These types have been available since Go 1.19,
which is the minimum supported version of Go for Zap.

This allows us to drop one dependency from Zap.
The version of multierr was bumped to pick up uber-go/multierr#72
which made a similar change to that package.

This was nearly a drop-in, save the following:

- There's no `Int*.Inc`; we have to use `Int*.Add(1)`
- There's no `Bool.Toggle`; we have to implement the CAS loop manually
@codecov
Copy link

codecov bot commented Mar 19, 2023

Codecov Report

Merging #1253 (0629789) into master (f2f1f41) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1253   +/-   ##
=======================================
  Coverage   98.23%   98.23%           
=======================================
  Files          49       49           
  Lines        3231     3231           
=======================================
  Hits         3174     3174           
  Misses         49       49           
  Partials        8        8           
Impacted Files Coverage Δ
level.go 100.00% <100.00%> (ø)
zapcore/sampler.go 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@mway mway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@mway mway merged commit 384e782 into master Mar 19, 2023
@mway mway deleted the sync-atomic branch March 19, 2023 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants