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

Convert APIs to async #84

Merged
merged 21 commits into from
Aug 3, 2022
Merged

Convert APIs to async #84

merged 21 commits into from
Aug 3, 2022

Conversation

yim-lee
Copy link
Member

@yim-lee yim-lee commented Jun 17, 2022

Change ping and pingRequest to async and remove onResponse callback parameter.

This change requires Swift 5.5.

DO NOT MERGE for there are broken tests

Sources/SWIM/Peer.swift Show resolved Hide resolved
Sources/SWIMNIOExample/NIOPeer.swift Outdated Show resolved Hide resolved
Sources/SWIMNIOExample/NIOPeer.swift Show resolved Hide resolved
Tests/SWIMNIOExampleTests/SWIMNIOEmbeddedTests.swift Outdated Show resolved Hide resolved
@ktoso ktoso marked this pull request as draft June 17, 2022 09:16
Sources/SWIM/Peer.swift Outdated Show resolved Hide resolved
Copy link
Member Author

@yim-lee yim-lee left a comment

Choose a reason for hiding this comment

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

This is ready for review.

Tests/SWIMNIOExampleTests/SWIMNIOEmbeddedTests.swift Outdated Show resolved Hide resolved
Tests/SWIMNIOExampleTests/SWIMNIOEmbeddedTests.swift Outdated Show resolved Hide resolved
Tests/SWIMNIOExampleTests/SWIMNIOEmbeddedTests.swift Outdated Show resolved Hide resolved
@yim-lee yim-lee marked this pull request as ready for review June 19, 2022 00:57
@yim-lee yim-lee changed the title [DNM][WIP] Convert APIs to async Convert APIs to async Jun 19, 2022
@ktoso
Copy link
Member

ktoso commented Jul 29, 2022

Looking in depth now, along with apple/swift-distributed-actors#977

I think by landing both updates at the same time we can bump APIs and make them all async native etc 👍

@ktoso ktoso self-requested a review July 29, 2022 08:03
Sources/SWIM/Peer.swift Outdated Show resolved Hide resolved
@ktoso
Copy link
Member

ktoso commented Aug 2, 2022

Removed the embedded tests for now, way too much pain than they're worth -- until we get an async/await aware embedded NIO testing story (soon).

Ticket here: Bring back embedded SWIMNIO tests, which are had without async-aware "Embedded" infra #86

@@ -46,7 +46,7 @@ extension SWIM {
public let localSuspicionStartedAt: DispatchTime? // could be "status updated at"?

/// Create a new member.
public init(peer: SWIMPeer, status: SWIM.Status, protocolPeriod: UInt64, suspicionStartedAt: DispatchTime? = nil) {
public init(peer: Peer, status: SWIM.Status, protocolPeriod: UInt64, suspicionStartedAt: DispatchTime? = nil) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Do we want to change suspicionStartedAt to an Instant type instead?

Copy link
Member

Choose a reason for hiding this comment

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

I seem to remember instant isn't great for this but maybe I'm wrong...?

Copy link
Member

Choose a reason for hiding this comment

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

I ticketified #87

Sources/SWIM/SWIMInstance.swift Outdated Show resolved Hide resolved
Sources/SWIM/SWIMInstance.swift Show resolved Hide resolved
Sources/SWIM/SWIMProtocol.swift Show resolved Hide resolved
Sources/SWIM/SWIMProtocol.swift Outdated Show resolved Hide resolved
Sources/SWIM/SWIMProtocol.swift Outdated Show resolved Hide resolved
Sources/SWIM/SWIMProtocol.swift Outdated Show resolved Hide resolved
}

/// Represents number of nanoseconds within given time unit
enum PrettyTimeUnit: Int64 {
Copy link
Member Author

Choose a reason for hiding this comment

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

Used?

Copy link
Member

Choose a reason for hiding this comment

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

removed, thanks!

case nanoseconds = 1
// @formatter:on

var abbreviated: String {
Copy link
Member Author

Choose a reason for hiding this comment

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

Used?

Copy link
Member

Choose a reason for hiding this comment

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

seems not, removing --

self.timeout = timeout
self.message = message
}

public var description: String {
"SWIMNIOTimeoutError(timeout: \(self.timeout.prettyDescription), \(self.message))"
"SWIMNIOTimeoutError(timeout: \(self.timeout), \(self.message))"
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't want to keep prettyDescription?

Copy link
Member

Choose a reason for hiding this comment

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

Just because I didn't want to make a public extension with the pretty stuff on the Swift types, figured we shouldn't add public API on those

Copy link
Member

Choose a reason for hiding this comment

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

Sorry my bad, should be fine since it is internal here

@ktoso ktoso merged commit 68b2da6 into apple:main Aug 3, 2022
@yim-lee yim-lee deleted the async-await branch August 3, 2022 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants