Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Unix domain socket support (line#4846)
Motivation: In service mesh environment, it's quite common for a sidecar to communicate with an app using a Unix domain socket. Armeria could be used more efficiently than using TCP/IP in such a scenarios with domain socket support. Modifications: - Updated the various places to support domain sockets, as listed below - Common changes: - Added `DomainSocketAddress` - `DomainSocketAddress` is a subtype of `InetSocketAddress` for backward compatibility with the existing API that returns `InetSocketAddress` rather than `SocketAddress`. - (Breaking) Changed the return type of `RequestContext.localAddress()` and `remoteAddress()` from `SocketAddress` and `InetSocketAddress` because `DomainSocketAddress` is now an `InetSocketAddress`. - (Breaking) The parameter type of the following methods has been changed from `SocketAddress` to `InetSocketAddress`: - `ClientRequestContextBuilder.localAddress()` - `ClientRequestContextBuilder.remoteAddress()` - `ServiceRequestContextBuilder.localAddress()` - `ClientRequestContextBuilder.remoteAddress()` - Added various getters to `TransportType` and `TransportTypeProvider` so it provides the transport-specific information about domain socket classes and whether the transport supports domain sockets - Added `ChannelUtil.localAddress()` and `remoteAddress()` and replace the direct invocation of `Channel.localAddress()` and `remoteAddress()` to convert Netty's `DomainSocketAddress` into ours. - Updated Netty to 4.1.92 that contains the fix for the problem where `DomainSocketChannel` returns `null` addresses. - Added `ChannelUtil.isTcpOption()` to determine whether the given `ChannelOption` is for TCP or not, so that a user doesn't get a WARN log when they use domain sockets - Server-side changes: - Added `ServerPort.isDomainSocket()` - Updated `Server` and `HttpServerHandler` to support domain sockets. - Made `ServerRule` and `ServerExtension` not instantiate their default `WebClient`s lazily, so that a user can start a serer that listens only on a domain socket - Client-side changes: - Added domain socket address support to `Endpoint`: - Made `Endpoint` accept a domain socket address in its `host` field - Added `Endpoint.of(SocketAddress)` so that a user can easily create an `Endpoint` from an `InetSocketAddress` or a `DomainSocketAddress` - Added `Endpoint.isDomainSocket()` - Updated `HttpClientFactory`, `HttpChannelPool`, `HttpClientDelegate`, `HttpClientPipelineConfigurator` and `SessionProtocolNegotiationCache` to support domain sockets Result: - Armeria is now capable of serving/sending requests from/to a Unix domain socket, making it more service-mesh-friendly. - (Breaking) Changed the return type of `RequestContext.localAddress()` and `remoteAddress()` from `SocketAddress` and `InetSocketAddress` because `DomainSocketAddress` is now an `InetSocketAddress`. - (Breaking) The parameter type of the following methods has been changed from `SocketAddress` to `InetSocketAddress`: - `ClientRequestContextBuilder.localAddress()` - `ClientRequestContextBuilder.remoteAddress()` - `ServiceRequestContextBuilder.localAddress()` - `ClientRequestContextBuilder.remoteAddress()` --------- Co-authored-by: jrhee17 <guins_j@guins.org> Co-authored-by: Ikhun Um <ih.pert@gmail.com> Co-authored-by: minux <songmw725@gmail.com>
- Loading branch information