Skip to content

Basics: make ObservabilityScope conform to Sendable #6089

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

Merged
merged 65 commits into from
Mar 15, 2023

Conversation

MaxDesiatov
Copy link
Contributor

@MaxDesiatov MaxDesiatov commented Jan 31, 2023

Depends on #6022.

Motivation:

New actor HTTPClient can't take ObservabilityScope as an argument to its functions as it's not Sendable. This is the only major API difference between HTTPClient and LegacyHTTPClient, which we'd like to resolve.

Modifications:

Marked SwiftToolObservabilityHandler.OutputHandler, ThreadSafeBox, ThreadSafeArrayStore, and ThreadSafeKeyValueStore either UnsafeSendable or @unchecked Sendable, depending on Swift version. Made ObservabilityMetadata: Sendable by requiring its keys and values to be sendable. Added additional Sendable requirement on DiagnosticsHandler.

Result:

This allows passing ObservabilityScope instances to HTTPClient/execute.

neonichu
neonichu previously approved these changes Jan 31, 2023
When implementing `async`-friendly `HTTPClient`, we need to make `FileSystem` conform to `Sendable`. That would imply some kind of locking in `FileSystem` implementation. A more straightforward approach seems to make those actors. Since `FileSystem` is used in many places through our codebase, let's make the transition incremental by introducing a new `protocol AsyncFileSystem` first, which requires conforming protocols to be actors.
Additionally, moved `HTTPClientHeaders`, `HTTPClientRequest`, and `HTTPClientResponse` to separate files for easier maintenance.
Also add `SendableTimeInterval` to use instead of `DispatchTimeInterval` in `HTTPClient`
@MaxDesiatov

This comment was marked as duplicate.

1 similar comment
@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov

This comment was marked as duplicate.

@MaxDesiatov

This comment was marked as outdated.

@MaxDesiatov

This comment was marked as outdated.

@MaxDesiatov

This comment was marked as duplicate.

@MaxDesiatov

This comment was marked as duplicate.

@MaxDesiatov
Copy link
Contributor Author

MaxDesiatov commented Feb 2, 2023

Not sure how to fix the macOS self-hosted job error with old Xcode on CI, and it isn't reproducible locally with newer Xcode. Putting this into a draft state until macOS CI nodes are updated to newer Xcode and Swift versions.

@MaxDesiatov MaxDesiatov added the WIP Work in progress label Feb 2, 2023
@MaxDesiatov MaxDesiatov marked this pull request as draft February 2, 2023 22:33
auto-merge was automatically disabled February 2, 2023 22:33

Pull request was converted to draft

…xd/sendable-observability

# Conflicts:
#	Sources/Basics/Concurrency/ThreadSafeArrayStore.swift
#	Sources/Basics/Concurrency/ThreadSafeBox.swift
@MaxDesiatov

This comment was marked as outdated.

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test Windows

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test linux

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test windows

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test Windows

@MaxDesiatov MaxDesiatov marked this pull request as ready for review March 13, 2023 12:37
@MaxDesiatov MaxDesiatov removed the WIP Work in progress label Mar 13, 2023
@MaxDesiatov MaxDesiatov requested a review from tomerd March 13, 2023 12:50
@MaxDesiatov MaxDesiatov merged commit 434baa9 into main Mar 15, 2023
@MaxDesiatov MaxDesiatov deleted the maxd/sendable-observability branch March 15, 2023 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants