Explorar o código

Make ServerTransport protocol possible to use with structured concurrency (#1865)

Motivation:

The existing `ServerProtocol` has some design issues: its `listen` method returns the async sequence of streams to be handled, while at the same time it's `async` and must run for as long as the transport is up and running. This means we'll never get the sequence of streams back in most transport implementations (such as H2).

Modifications:

This PR tries to solve this by changing the protocol so that the `listen` method now takes a closure which allows handling an individual stream. This forces the transport implementations to maintain the right structured task hierarchy, as tasks to run this stream handler will have to be added as children of the long-running "listen" task.

Result:

Server Transports can now be used in structured concurrency.
Gustavo Cairo hai 1 ano
pai
achega
5e37317b97

+ 6 - 0
Sources/GRPCHTTP2TransportNIOPosix/Empty.swift → Sources/GRPCHTTP2TransportNIOPosix/GRPCHTTP2TransportNIOPosix.swift

@@ -13,3 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+import GRPCCore
+
+@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
+public struct GRPCHTTP2TransportNIOPosix {
+}

+ 6 - 0
Sources/GRPCHTTP2TransportNIOTransportServices/Empty.swift → Sources/GRPCHTTP2TransportNIOTransportServices/GRPCHTTP2TransportNIOTransportServices.swift

@@ -13,3 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+import GRPCCore
+
+@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
+public struct GRPCHTTP2TransportNIOTransportServices {
+}