-
Notifications
You must be signed in to change notification settings - Fork 434
Restructure in-process transport #2071
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
Restructure in-process transport #2071
Conversation
Motivation: To create a connected pair of `ServerTransport` and `ClientTransport`, users need to call `InProcessTransport.makePair(serviceConfig:)` which returns a tuple. The spelling of this API can be more intuitive and simple. Modifications: - Restructure `InProcessTransport` to include two properties: `server` (the `ServerTransport`) and `client` (the `ClientTransport`), and an `init(serviceConfig:)` that pairs these properties. - Add missing GRPCInProcessTransport dependency to GRPCCore test target. Result: The spelling of the `InProcessTransport` API will be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks fine, left a few comments which need resolving.
Sources/GRPCCore/GRPCClient.swift
Outdated
/// let inProcessServerTransport = InProcessTransport.Server() | ||
/// let inProcessClientTransport = InProcessTransport.Client(serverTransport: inProcessServerTransport) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was wrong before your changes: can you update it?
Sources/GRPCCore/GRPCServer.swift
Outdated
/// ```swift | ||
/// // Create and an in-process transport. | ||
/// let inProcessTransport = InProcessServerTransport() | ||
/// let inProcessTransport = InProcessTransport.Server() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, this is also wrong, can you update this one?
@@ -0,0 +1,359 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rename this file? Normally when you extend a type you name the file <ThingBeingExtended>+<WhatItsExtendedWith>.swift
so in this case InProcessTransport+Client.swift
.
This makes things much easier to find: if you're looking for the in-process client transport then the obvious thing to search for is "InProcessTransport" because that's much more specific than "Client".
/// and a client using that server transport. | ||
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) | ||
public struct InProcessTransport: Sendable { | ||
public let server = Self.Server() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: initialize this in the init
public let server = Self.Server() | |
public let server: Self.Server |
public let server = Self.Server() | ||
public let client: Self.Client | ||
|
||
/// Initializes a new ``InProcessTransport`` pairing a ``ServerTransport`` and a ``ClientTransport``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Initializes a new ``InProcessTransport`` pairing a ``ServerTransport`` and a ``ClientTransport``. | |
/// Initializes a new ``InProcessTransport`` pairing a ``Client`` and a ``Server``. |
@@ -0,0 +1,83 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rename this file to be InProcessTransport+Server.swift
?
Motivation:
To create a connected pair of
ServerTransport
andClientTransport
, users need to callInProcessTransport.makePair(serviceConfig:)
which returns a tuple. The spelling of this API can be more intuitive and simple.Modifications:
InProcessTransport
to include two properties:server
(theServerTransport
) andclient
(theClientTransport
), and aninit(serviceConfig:)
that pairs these properties.Result:
The spelling of the
InProcessTransport
API will be better.