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 = HttpServer.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 TcpServerTests method testTcpServerWithDomainSockets.
@Test
void testTcpServerWithDomainSockets() throws Exception {
assumeThat(LoopResources.hasNativeSupport()).isTrue();
DisposableServer disposableServer = TcpServer.create().bindAddress(() -> new DomainSocketAddress("/tmp/test.sock")).wiretap(true).handle((in, out) -> out.send(in.receive().retain())).bindNow();
Connection conn = TcpClient.create().remoteAddress(disposableServer::address).wiretap(true).connectNow();
conn.outbound().sendString(Flux.just("1", "2", "3")).then().subscribe();
CountDownLatch latch = new CountDownLatch(1);
conn.inbound().receive().asString().doOnNext(s -> {
if (s.endsWith("3")) {
latch.countDown();
}
}).subscribe();
assertThat(latch.await(30, TimeUnit.SECONDS)).as("latch await").isTrue();
conn.disposeNow();
disposableServer.disposeNow();
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project reactor-netty by reactor.
the class UdpClientTest method domainSocketsSmokeTest.
@Test
void domainSocketsSmokeTest() throws Exception {
assumeThat(LoopResources.hasNativeSupport()).isTrue();
LoopResources resources = LoopResources.create("domainSocketsSmokeTest");
CountDownLatch latch = new CountDownLatch(4);
Connection server = null;
Connection client1 = null;
Connection client2 = null;
try {
server = UdpServer.create().bindAddress(UdpClientTest::newDomainSocketAddress).runOn(resources).handle((in, out) -> in.receiveObject().map(o -> {
if (o instanceof DomainDatagramPacket) {
DomainDatagramPacket received = (DomainDatagramPacket) o;
ByteBuf buffer = received.content();
System.out.println("Server received " + buffer.readCharSequence(buffer.readableBytes(), CharsetUtil.UTF_8));
ByteBuf buf1 = Unpooled.copiedBuffer("echo ", CharsetUtil.UTF_8);
ByteBuf buf2 = Unpooled.copiedBuffer(buf1, buffer);
buf1.release();
return new DomainDatagramPacket(buf2, received.sender());
} else {
return Mono.error(new Exception());
}
}).flatMap(out::sendObject)).wiretap(true).bind().block(Duration.ofSeconds(30));
assertThat(server).isNotNull();
DomainSocketAddress address = (DomainSocketAddress) server.address();
client1 = UdpClient.create().bindAddress(UdpClientTest::newDomainSocketAddress).remoteAddress(() -> address).runOn(resources).handle((in, out) -> {
in.receive().subscribe(b -> latch.countDown());
return out.sendString(Mono.just("ping1")).then(out.sendString(Mono.just("ping2"))).neverComplete();
}).wiretap(true).connect().block(Duration.ofSeconds(30));
assertThat(client1).isNotNull();
client2 = UdpClient.create().bindAddress(UdpClientTest::newDomainSocketAddress).remoteAddress(() -> address).runOn(resources).handle((in, out) -> {
in.receive().subscribe(b -> latch.countDown());
return out.sendString(Mono.just("ping3")).then(out.sendString(Mono.just("ping4"))).neverComplete();
}).wiretap(true).connect().block(Duration.ofSeconds(30));
assertThat(client2).isNotNull();
assertThat(latch.await(30, TimeUnit.SECONDS)).as("latch await").isTrue();
} finally {
if (server != null) {
server.disposeNow();
}
if (client1 != null) {
client1.disposeNow();
}
if (client2 != null) {
client2.disposeNow();
}
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.netty.channel.unix.DomainSocketAddress in project reactor-netty by reactor.
the class UdpClientTest method testUdpClientWithDomainSocketsConnectionRefused.
@Test
void testUdpClientWithDomainSocketsConnectionRefused() {
assumeThat(LoopResources.hasNativeSupport()).isTrue();
UdpClient.create().remoteAddress(() -> new DomainSocketAddress("/tmp/test.sock")).connect().as(StepVerifier::create).expectError(FileNotFoundException.class).verify(Duration.ofSeconds(5));
}
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) {
HttpClient client = HttpClient.create().remoteAddress(// <1>
() -> new DomainSocketAddress("/tmp/test.sock"));
client.get().uri("/").response().block();
}
Aggregations