ConnectionFactory.swift 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright 2024, gRPC Authors All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package import NIOCore
  17. package import NIOHTTP2
  18. internal import NIOPosix
  19. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  20. package protocol HTTP2Connector: Sendable {
  21. func establishConnection(to address: SocketAddress) async throws -> HTTP2Connection
  22. }
  23. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  24. package struct HTTP2Connection: Sendable {
  25. /// The underlying TCP connection wrapped up for use with gRPC.
  26. var channel: NIOAsyncChannel<ClientConnectionEvent, Void>
  27. /// An HTTP/2 stream multiplexer.
  28. var multiplexer: NIOHTTP2Handler.AsyncStreamMultiplexer<Void>
  29. /// Whether the connection is insecure (i.e. plaintext).
  30. var isPlaintext: Bool
  31. package init(
  32. channel: NIOAsyncChannel<ClientConnectionEvent, Void>,
  33. multiplexer: NIOHTTP2Handler.AsyncStreamMultiplexer<Void>,
  34. isPlaintext: Bool
  35. ) {
  36. self.channel = channel
  37. self.multiplexer = multiplexer
  38. self.isPlaintext = isPlaintext
  39. }
  40. }