Skip to content

updating error type to use computed properties #559

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Sources/ConnectionPoolModule/ConnectionPoolError.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@

public struct ConnectionPoolError: Error, Hashable {
enum Base: Error, Hashable {
@usableFromInline
enum Base: Error, Hashable, Sendable {
case requestCancelled
case poolShutdown
}

private let base: Base
@usableFromInline
let base: Base

@inlinable
Comment on lines +9 to +12
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this one now marked as @inlinable?

Copy link
Author

Choose a reason for hiding this comment

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

It doesn't need to be, I was cargo-culting the pattern I saw in apple/swift-nio#3229, which added @inlinable to the initializers as well. I presumed that was helping with performance effects from inlining in that code, but I'm replicating that somewhat blindly.

Happy to pull it back out.

init(_ base: Base) { self.base = base }

/// The connection requests got cancelled
public static let requestCancelled = ConnectionPoolError(.requestCancelled)
public static var requestCancelled: Self {
ConnectionPoolError(.requestCancelled)
}
/// The connection requests can't be fulfilled as the pool has already been shutdown
public static let poolShutdown = ConnectionPoolError(.poolShutdown)
public static var poolShutdown: Self {
ConnectionPoolError(.poolShutdown)
}
}
Loading