Skip to content
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

chore(tls): remove redundant i/o bounds #3647

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

cratelyn
Copy link
Collaborator

this commit removes a redundant set of trait bounds from linkerd_tls::Client<L, C>'s tower::Service<T> implementation.

this client type is generic over a C-typed MakeConnection. this trait is effectively an alias for particular services, and already by definition is prerequisite upon Connection responses that are an asynchronous reader/writer.

see the definition of the trait, here:

// linkerd/stack/src/connect.rs

pub trait MakeConnection<T> {
    /// An I/O type that represents a connection to the remote endpoint.
    type Connection: AsyncRead + AsyncWrite;

    /// Metadata associated with the established connection.
    type Metadata;

    type Error: Into<Error>;

    type Future: Future<Output = Result<(Self::Connection, Self::Metadata), Self::Error>>;

    /// Determines whether the connector is ready to establish a connection.
    fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;

    /// Establishes a connection.
    fn connect(&mut self, t: T) -> Self::Future;

    // contd...
}

thus, we can remove these bounds from the tls client. the connection is already, by virtue of C: MakeConnection, an AsyncRead + AsyncWrite type.

see linkerd/linkerd2#8733.

this commit removes a redundant set of trait bounds from
`linkerd_tls::Client<L, C>`'s `tower::Service<T>` implementation.

this client type is generic over a `C`-typed `MakeConnection`. this
trait is effectively an alias for particular services, and already by
definition is prerequisite upon `Connection` responses that are
an asynchronous reader/writer.

see the definition of the trait, here:

```rust
// linkerd/stack/src/connect.rs

pub trait MakeConnection<T> {
    /// An I/O type that represents a connection to the remote endpoint.
    type Connection: AsyncRead + AsyncWrite;

    /// Metadata associated with the established connection.
    type Metadata;

    type Error: Into<Error>;

    type Future: Future<Output = Result<(Self::Connection, Self::Metadata), Self::Error>>;

    /// Determines whether the connector is ready to establish a connection.
    fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;

    /// Establishes a connection.
    fn connect(&mut self, t: T) -> Self::Future;

    // contd...
}
```

thus, we can remove these bounds from the tls client. the connection is
already, by virtue of `C: MakeConnection`, an `AsyncRead + AsyncWrite`
type.

see linkerd/linkerd2#8733.

Signed-off-by: katelyn martin <[email protected]>
@cratelyn cratelyn marked this pull request as ready for review February 24, 2025 15:55
@cratelyn cratelyn requested a review from a team as a code owner February 24, 2025 15:55
@cratelyn cratelyn merged commit 8e5d0fd into main Feb 24, 2025
15 checks passed
@cratelyn cratelyn deleted the kate/remove-redundant-io-bounds branch February 24, 2025 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants