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

Add Unix domain socket support #4846

Merged
merged 34 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1d3f630
Add server-side Unix domain socket support
trustin May 19, 2023
41ee453
Address the comments from @ikhoon
trustin May 20, 2023
999eca6
Domain socket support on macOS
trustin May 20, 2023
d473068
Lint
trustin May 22, 2023
6ea5bee
Add `Endpoint.toSocketAddress()` and `DomainSocketAddress.asEndpoint()`
trustin May 22, 2023
20c6709
Make `Endpoint` cache `InetSocketAddress` more aggressively / Addres…
trustin May 23, 2023
a5aa7fe
Simplify SessionProtocolNegotiationCache key generation
trustin May 23, 2023
2ac54ad
Update core/src/main/java/com/linecorp/armeria/client/Endpoint.java
trustin May 25, 2023
4b4c98c
Update core/src/main/java/com/linecorp/armeria/client/HttpClientFacto…
trustin May 25, 2023
73f5d22
Address the comments from @jrhee17 / Normalize IP addresses wherever …
trustin May 25, 2023
a4b24f6
Merge branch 'main' into uds
trustin May 25, 2023
c604c9c
Merge branch 'main' into uds
trustin May 30, 2023
ff89907
Merge branch 'main' into uds
trustin May 30, 2023
4f1d5fb
Fix an exception in `DefaultEventLoopScheduler`
trustin May 30, 2023
3f5bc3e
Don't throw exception when setting port/IP on domain socket endpoint
trustin May 30, 2023
9c48404
Make a domain socket endpoint always has predefined IP address and port
trustin May 30, 2023
1d2b297
Fix Endpoint.authority()
trustin May 30, 2023
6733934
Fix a bug in Endpoint.withHost()
trustin May 30, 2023
92ebac1
Address the comment from @ikhoon / Add `Endpoint.{with,without}Defaul…
trustin May 30, 2023
54aee42
Update core/src/main/java/com/linecorp/armeria/client/Endpoint.java
ikhoon Jun 3, 2023
324d470
Merge branch 'main' into pr-4846-trustin-uds
ikhoon Jun 3, 2023
37cbac2
resolve conflicts
ikhoon Jun 3, 2023
ee13b32
Remove an unused import
ikhoon Jun 3, 2023
80e7329
Merge branch 'main' into uds
ikhoon Jun 7, 2023
a4bcd25
Merge branch 'main' into uds
trustin Jun 7, 2023
5939891
Update core/src/main/java/com/linecorp/armeria/client/Endpoint.java
trustin Jun 7, 2023
22f637d
Update core/src/main/java/com/linecorp/armeria/client/Endpoint.java
trustin Jun 7, 2023
0e7bc01
Update core/src/main/java/com/linecorp/armeria/client/Endpoint.java
trustin Jun 7, 2023
fb84c46
Add `unix:` prefix to the boss thread names
trustin Jun 7, 2023
7834c7d
Update core/src/main/java/com/linecorp/armeria/client/HttpChannelPool…
trustin Jun 7, 2023
ac354c1
Address the comment by @jrhee17
trustin Jun 7, 2023
1ffd2ec
Lint
trustin Jun 7, 2023
168e71c
Oops
trustin Jun 8, 2023
4de1794
Lint
trustin Jun 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static com.google.common.base.MoreObjects.firstNonNull;

import java.net.SocketAddress;
import java.net.InetSocketAddress;

import com.linecorp.armeria.client.ClientRequestContext;
import com.linecorp.armeria.common.HttpRequest;
Expand Down Expand Up @@ -94,12 +94,12 @@ public void parse(HttpResponse response, TraceContext context, SpanCustomizer sp
span.tag(SpanTags.TAG_HTTP_SERIALIZATION_FORMAT, serFmt);
}

final SocketAddress raddr = ctx.remoteAddress();
final InetSocketAddress raddr = ctx.remoteAddress();
if (raddr != null) {
span.tag(SpanTags.TAG_ADDRESS_REMOTE, raddr.toString());
}

final SocketAddress laddr = ctx.localAddress();
final InetSocketAddress laddr = ctx.localAddress();
if (laddr != null) {
span.tag(SpanTags.TAG_ADDRESS_LOCAL, laddr.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

package com.linecorp.armeria.internal.common.brave;

import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;

import com.linecorp.armeria.common.RequestContext;
import com.linecorp.armeria.common.logging.RequestLog;
Expand Down Expand Up @@ -54,19 +52,9 @@ public static void logWireReceive(Span span, long wireReceiveTimeNanos, RequestL
}

public static boolean updateRemoteEndpoint(Span span, RequestContext ctx) {
final SocketAddress remoteAddress = ctx.remoteAddress();
final InetAddress address;
final int port;
if (remoteAddress instanceof InetSocketAddress) {
final InetSocketAddress socketAddress = (InetSocketAddress) remoteAddress;
address = socketAddress.getAddress();
port = socketAddress.getPort();
} else {
address = null;
port = 0;
}
if (address != null) {
return span.remoteIpAndPort(address.getHostAddress(), port);
final InetSocketAddress remoteAddress = ctx.remoteAddress();
if (remoteAddress != null) {
return span.remoteIpAndPort(remoteAddress.getAddress().getHostAddress(), remoteAddress.getPort());
}
return false;
}
Expand Down
20 changes: 12 additions & 8 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,22 @@ dependencies {
api libs.netty.codec.haproxy
api libs.netty.codec.http2
api libs.netty.resolver.dns
implementation(variantOf(libs.netty.transport.native.unix.common) { classifier("linux-x86_64") })
implementation(variantOf(libs.netty.transport.native.epoll) { classifier("linux-x86_64") })
implementation(variantOf(libs.netty.resolver.dns.native.macos) { classifier("osx-x86_64") })
implementation(variantOf(libs.netty.resolver.dns.native.macos) { classifier("osx-aarch_64") })
implementation libs.netty.handler.proxy

// Note that tcnative now needs explicit classifiers
// Related: https://github.com/netty/netty-tcnative/pull/709
// Netty native libraries
['linux-x86_64', 'linux-aarch_64'].each { arch ->
implementation(variantOf(libs.netty.transport.native.unix.common) { classifier(arch) })
implementation(variantOf(libs.netty.transport.native.epoll) { classifier(arch) })
optionalImplementation(variantOf(libs.netty.io.uring) { classifier(arch) })
}
['osx-x86_64', 'osx-aarch_64'].each { arch ->
implementation(variantOf(libs.netty.transport.native.unix.common) { classifier(arch) })
implementation(variantOf(libs.netty.transport.native.kqueue) { classifier(arch) })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙇‍♂️

implementation(variantOf(libs.netty.resolver.dns.native.macos) { classifier(arch) })
}
['linux-x86_64', 'linux-aarch_64', 'osx-x86_64', 'osx-aarch_64', 'windows-x86_64'].each { arch ->
implementation(variantOf(libs.netty.tcnative.boringssl) { classifier(arch) })
}
implementation libs.netty.handler.proxy
optionalImplementation(variantOf(libs.netty.io.uring) { classifier("linux-x86_64") })

// TestNG
testImplementation libs.testng
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import static java.util.Objects.requireNonNull;

import java.net.SocketAddress;
import java.net.InetSocketAddress;
import java.net.URI;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -200,12 +200,12 @@ public ClientRequestContextBuilder id(RequestId id) {
}

@Override
public ClientRequestContextBuilder remoteAddress(SocketAddress remoteAddress) {
public ClientRequestContextBuilder remoteAddress(InetSocketAddress remoteAddress) {
return (ClientRequestContextBuilder) super.remoteAddress(remoteAddress);
}

@Override
public ClientRequestContextBuilder localAddress(SocketAddress localAddress) {
public ClientRequestContextBuilder localAddress(InetSocketAddress localAddress) {
return (ClientRequestContextBuilder) super.localAddress(localAddress);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ private AbstractEventLoopState state(SessionProtocol sessionProtocol,
secondTryHost = null;
}

final int port = endpoint.hasPort() ? endpoint.port() : sessionProtocol.defaultPort();
final Endpoint endpointWithPort = endpoint.withPort(port);
final Endpoint endpointWithPort = endpoint.withDefaultPort(sessionProtocol);
final int port = endpointWithPort.port();
final boolean isHttp1 = isHttp1(sessionProtocol, endpointWithPort);
final StateKey firstKey = new StateKey(firstTryHost, port, isHttp1);
AbstractEventLoopState state = states.get(firstKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public HttpResponse execute(HttpRequest req, RequestOptions requestOptions) {
final RequestTarget reqTarget = RequestTarget.forClient(originalPath, prefix);
if (reqTarget == null) {
return abortRequestAndReturnFailureResponse(
req, new IllegalArgumentException("Invalid path: " + originalPath));
req, new IllegalArgumentException("Invalid request target: " + originalPath));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't always a path but can be an absolute URI, so I changed it to 'request target'.

}

final EndpointGroup endpointGroup;
Expand Down
Loading