use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
DisposableServer server = TcpServer.create().bindAddress(// <1>
() -> new DomainSocketAddress("/tmp/test.sock")).bindNow();
server.onDispose().block();
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project reactor-netty by reactor.
the class UdpClientTest method newDomainSocketAddress.
private static DomainSocketAddress newDomainSocketAddress() {
try {
File tempFile = Files.createTempFile("UdpClientTest", "UDS").toFile();
assertThat(tempFile.delete()).isTrue();
tempFile.deleteOnExit();
return new DomainSocketAddress(tempFile);
} catch (Exception e) {
throw new RuntimeException("Error creating a temporary file", e);
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project reactor-netty by reactor.
the class HttpServerTests method doTestHttpServerWithDomainSockets.
private void doTestHttpServerWithDomainSockets(HttpServer server, HttpClient client, String expectedScheme) {
assumeThat(LoopResources.hasNativeSupport()).isTrue();
disposableServer = server.bindAddress(() -> new DomainSocketAddress("/tmp/test.sock")).wiretap(true).handle((req, res) -> {
req.withConnection(conn -> {
assertThat(conn.channel().localAddress()).isNull();
assertThat(conn.channel().remoteAddress()).isNull();
assertThat(req.hostAddress()).isNull();
assertThat(req.remoteAddress()).isNull();
assertThat(req.scheme()).isNotNull().isEqualTo(expectedScheme);
});
assertThat(req.requestHeaders().get(HttpHeaderNames.HOST)).isEqualTo("localhost");
return res.send(req.receive().retain());
}).bindNow();
String response = client.remoteAddress(disposableServer::address).wiretap(true).post().uri("/").send(ByteBufFlux.fromString(Flux.just("1", "2", "3"))).responseContent().aggregate().asString().block(Duration.ofSeconds(30));
assertThat(response).isEqualTo("123");
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project netty by netty.
the class EpollSocketTestPermutation method newSocketAddress.
public static DomainSocketAddress newSocketAddress() {
try {
File file = File.createTempFile("netty", "dsocket");
file.delete();
return new DomainSocketAddress(file);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project beam by apache.
the class ManagedChannelFactory method forDescriptor.
public ManagedChannel forDescriptor(ApiServiceDescriptor apiServiceDescriptor) {
ManagedChannelBuilder<?> channelBuilder;
switch(type) {
case EPOLL:
SocketAddress address = SocketAddressFactory.createFrom(apiServiceDescriptor.getUrl());
channelBuilder = NettyChannelBuilder.forAddress(address).channelType(address instanceof DomainSocketAddress ? EpollDomainSocketChannel.class : EpollSocketChannel.class).eventLoopGroup(new EpollEventLoopGroup());
break;
case DEFAULT:
channelBuilder = ManagedChannelBuilder.forTarget(apiServiceDescriptor.getUrl());
break;
case IN_PROCESS:
channelBuilder = InProcessChannelBuilder.forName(apiServiceDescriptor.getUrl());
break;
default:
throw new IllegalStateException("Unknown type " + type);
}
channelBuilder = channelBuilder.usePlaintext().maxInboundMessageSize(Integer.MAX_VALUE).intercept(interceptors);
if (directExecutor) {
channelBuilder = channelBuilder.directExecutor();
}
return channelBuilder.build();
}
Aggregations