Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions Sources/GRPCHTTP2Core/Client/HTTP2ClientTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension HTTP2ClientTransport {
}

extension HTTP2ClientTransport.Config {
public struct Compression: Sendable {
public struct Compression: Sendable, Hashable {
/// The default algorithm used for compressing outbound messages.
///
/// This can be overridden on a per-call basis via `CallOptions`.
Expand All @@ -51,7 +51,7 @@ extension HTTP2ClientTransport.Config {
}

@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
public struct Keepalive: Sendable {
public struct Keepalive: Sendable, Hashable {
/// The amount of time to wait after reading data before sending a keepalive ping.
///
/// - Note: The transport may choose to increase this value if it is less than 10 seconds.
Expand All @@ -73,7 +73,7 @@ extension HTTP2ClientTransport.Config {
}

@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
public struct Connection: Sendable {
public struct Connection: Sendable, Hashable {
/// The maximum amount of time a connection may be idle before it's closed.
///
/// Connections are considered idle when there are no open streams on them. Idle connections
Expand Down Expand Up @@ -103,7 +103,7 @@ extension HTTP2ClientTransport.Config {
}

@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
public struct Backoff: Sendable {
public struct Backoff: Sendable, Hashable {
/// The initial duration to wait before reattempting to establish a connection.
public var initial: Duration

Expand Down Expand Up @@ -135,7 +135,7 @@ extension HTTP2ClientTransport.Config {
}
}

public struct HTTP2: Sendable {
public struct HTTP2: Sendable, Hashable {
/// The max frame size, in bytes.
///
/// The actual value used is clamped to `(1 << 14) ... (1 << 24) - 1` (the min and max values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

private import GRPCCore
package import NIOCore

extension GRPCHTTP2Core.SocketAddress {
Expand All @@ -38,6 +39,22 @@ extension GRPCHTTP2Core.SocketAddress {
}

extension NIOCore.SocketAddress {
package init(_ socketAddress: GRPCHTTP2Core.SocketAddress) throws {
if let ipv4 = socketAddress.ipv4 {
self = try Self(ipv4)
} else if let ipv6 = socketAddress.ipv6 {
self = try Self(ipv6)
} else if let unixDomainSocket = socketAddress.unixDomainSocket {
self = try Self(unixDomainSocket)
} else {
throw RPCError(
code: .internalError,
message:
"Unsupported mapping to NIOCore/SocketAddress for GRPCHTTP2Core/SocketAddress: \(socketAddress)."
)
}
}

package init(_ address: GRPCHTTP2Core.SocketAddress.IPv4) throws {
try self.init(ipAddress: address.host, port: address.port)
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/GRPCHTTP2Core/Server/HTTP2ServerTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension HTTP2ServerTransport {
}

extension HTTP2ServerTransport.Config {
public struct Compression: Sendable {
public struct Compression: Sendable, Hashable {
/// Compression algorithms enabled for inbound messages.
///
/// - Note: `CompressionAlgorithm.none` is always supported, even if it isn't set here.
Expand All @@ -46,7 +46,7 @@ extension HTTP2ServerTransport.Config {
}

@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
public struct Keepalive: Sendable {
public struct Keepalive: Sendable, Hashable {
/// The amount of time to wait after reading data before sending a keepalive ping.
public var time: Duration

Expand Down Expand Up @@ -80,7 +80,7 @@ extension HTTP2ServerTransport.Config {
}

@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
public struct ClientKeepaliveBehavior: Sendable {
public struct ClientKeepaliveBehavior: Sendable, Hashable {
/// The minimum allowed interval the client is allowed to send keep-alive pings.
/// Pings more frequent than this interval count as 'strikes' and the connection is closed if there are
/// too many strikes.
Expand All @@ -107,7 +107,7 @@ extension HTTP2ServerTransport.Config {
}

@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
public struct Connection: Sendable {
public struct Connection: Sendable, Hashable {
/// The maximum amount of time a connection may exist before being gracefully closed.
public var maxAge: Duration?

Expand Down Expand Up @@ -142,7 +142,7 @@ extension HTTP2ServerTransport.Config {
}
}

public struct HTTP2: Sendable {
public struct HTTP2: Sendable, Hashable {
/// The maximum frame size to be used in an HTTP/2 connection.
public var maxFrameSize: Int

Expand Down Expand Up @@ -175,7 +175,7 @@ extension HTTP2ServerTransport.Config {
}
}

public struct RPC: Sendable {
public struct RPC: Sendable, Hashable {
/// The maximum request payload size.
public var maxRequestPayloadSize: Int

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@

public import GRPCCore
public import GRPCHTTP2Core // should be @usableFromInline
public import NIOCore
public import NIOCore // has to be public because of EventLoopGroup param in init
public import NIOPosix // has to be public because of default argument value in init

#if canImport(NIOSSL)
import NIOSSL
private import NIOSSL
#endif

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension HTTP2ClientTransport {
/// A ``GRPCCore/ClientTransport`` using HTTP/2 built on top of `NIOPosix`.
///
/// This transport builds on top of SwiftNIO's Posix networking layer and is suitable for use
/// on Linux and Darwin based platform (macOS, iOS, etc.) However, it's *strongly* recommended
/// on Linux and Darwin based platforms (macOS, iOS, etc.). However, it's *strongly* recommended
/// that if you are targeting Darwin platforms then you should use the `NIOTS` variant of
/// the ``GRPCHTTP2Core/HTTP2ClientTransport``.
///
Expand Down Expand Up @@ -62,7 +62,7 @@ extension HTTP2ClientTransport {
public struct Posix: ClientTransport {
private let channel: GRPCChannel

/// Creates a new Posix based HTTP/2 client transport.
/// Creates a new NIOPosix-based HTTP/2 client transport.
///
/// - Parameters:
/// - target: A target to resolve.
Expand Down Expand Up @@ -91,7 +91,6 @@ extension HTTP2ClientTransport {
)
}

// Configure a connector.
self.channel = GRPCChannel(
resolver: resolver,
connector: try Connector(eventLoopGroup: eventLoopGroup, config: config),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,24 +425,6 @@ extension HTTP2ServerTransport.Posix {
}
}

extension NIOCore.SocketAddress {
fileprivate init(_ socketAddress: GRPCHTTP2Core.SocketAddress) throws {
if let ipv4 = socketAddress.ipv4 {
self = try Self(ipv4)
} else if let ipv6 = socketAddress.ipv6 {
self = try Self(ipv6)
} else if let unixDomainSocket = socketAddress.unixDomainSocket {
self = try Self(unixDomainSocket)
} else {
throw RPCError(
code: .internalError,
message:
"Unsupported mapping to NIOCore/SocketAddress for GRPCHTTP2Core/SocketAddress: \(socketAddress)."
)
}
}
}

extension ServerBootstrap {
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
fileprivate func bind<Output: Sendable>(
Expand Down
Loading
Loading