Renames server package to core since boot now manages the server.
This commit is contained in:
@@ -28,8 +28,8 @@ import org.springframework.cloud.gateway.rsocket.registry.Registry;
|
||||
import org.springframework.cloud.gateway.rsocket.registry.RegistryRoutes;
|
||||
import org.springframework.cloud.gateway.rsocket.registry.RegistrySocketAcceptorFilter;
|
||||
import org.springframework.cloud.gateway.rsocket.route.Routes;
|
||||
import org.springframework.cloud.gateway.rsocket.server.GatewayRSocket;
|
||||
import org.springframework.cloud.gateway.rsocket.server.GatewayServerRSocketFactoryCustomizer;
|
||||
import org.springframework.cloud.gateway.rsocket.core.GatewayRSocket;
|
||||
import org.springframework.cloud.gateway.rsocket.core.GatewayServerRSocketFactoryCustomizer;
|
||||
import org.springframework.cloud.gateway.rsocket.socketacceptor.GatewaySocketAcceptor;
|
||||
import org.springframework.cloud.gateway.rsocket.socketacceptor.SocketAcceptorFilter;
|
||||
import org.springframework.cloud.gateway.rsocket.socketacceptor.SocketAcceptorPredicate;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.gateway.rsocket.server;
|
||||
package org.springframework.cloud.gateway.rsocket.core;
|
||||
|
||||
import io.micrometer.core.instrument.Tags;
|
||||
import io.rsocket.Payload;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.gateway.rsocket.server;
|
||||
package org.springframework.cloud.gateway.rsocket.core;
|
||||
|
||||
import org.springframework.cloud.gateway.rsocket.filter.RSocketFilter;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.gateway.rsocket.server;
|
||||
package org.springframework.cloud.gateway.rsocket.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.gateway.rsocket.server;
|
||||
package org.springframework.cloud.gateway.rsocket.core;
|
||||
|
||||
import org.springframework.cloud.gateway.rsocket.support.AsyncPredicate;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.gateway.rsocket.server;
|
||||
package org.springframework.cloud.gateway.rsocket.core;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Function;
|
||||
@@ -43,12 +43,12 @@ import org.springframework.cloud.gateway.rsocket.support.Metadata;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.springframework.cloud.gateway.rsocket.server.GatewayExchange.ROUTE_ATTR;
|
||||
import static org.springframework.cloud.gateway.rsocket.server.GatewayExchange.Type.FIRE_AND_FORGET;
|
||||
import static org.springframework.cloud.gateway.rsocket.server.GatewayExchange.Type.REQUEST_CHANNEL;
|
||||
import static org.springframework.cloud.gateway.rsocket.server.GatewayExchange.Type.REQUEST_RESPONSE;
|
||||
import static org.springframework.cloud.gateway.rsocket.server.GatewayExchange.Type.REQUEST_STREAM;
|
||||
import static org.springframework.cloud.gateway.rsocket.server.GatewayFilterChain.executeFilterChain;
|
||||
import static org.springframework.cloud.gateway.rsocket.core.GatewayExchange.ROUTE_ATTR;
|
||||
import static org.springframework.cloud.gateway.rsocket.core.GatewayExchange.Type.FIRE_AND_FORGET;
|
||||
import static org.springframework.cloud.gateway.rsocket.core.GatewayExchange.Type.REQUEST_CHANNEL;
|
||||
import static org.springframework.cloud.gateway.rsocket.core.GatewayExchange.Type.REQUEST_RESPONSE;
|
||||
import static org.springframework.cloud.gateway.rsocket.core.GatewayExchange.Type.REQUEST_STREAM;
|
||||
import static org.springframework.cloud.gateway.rsocket.core.GatewayFilterChain.executeFilterChain;
|
||||
|
||||
/**
|
||||
* Acts as a proxy to other registered sockets. Creates a GatewayExchange and attempts to
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.gateway.rsocket.server;
|
||||
package org.springframework.cloud.gateway.rsocket.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.gateway.rsocket.server;
|
||||
package org.springframework.cloud.gateway.rsocket.core;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
@@ -38,9 +38,9 @@ import org.springframework.cloud.gateway.rsocket.registry.Registry.RegisteredEve
|
||||
import org.springframework.cloud.gateway.rsocket.route.Route;
|
||||
import org.springframework.cloud.gateway.rsocket.support.Metadata;
|
||||
|
||||
import static org.springframework.cloud.gateway.rsocket.server.GatewayExchange.ROUTE_ATTR;
|
||||
import static org.springframework.cloud.gateway.rsocket.server.GatewayExchange.Type.REQUEST_STREAM;
|
||||
import static org.springframework.cloud.gateway.rsocket.server.GatewayFilterChain.executeFilterChain;
|
||||
import static org.springframework.cloud.gateway.rsocket.core.GatewayExchange.ROUTE_ATTR;
|
||||
import static org.springframework.cloud.gateway.rsocket.core.GatewayExchange.Type.REQUEST_STREAM;
|
||||
import static org.springframework.cloud.gateway.rsocket.core.GatewayFilterChain.executeFilterChain;
|
||||
|
||||
public class PendingRequestRSocket extends AbstractRSocket
|
||||
implements ResponderRSocket, Consumer<RegisteredEvent> {
|
||||
@@ -23,8 +23,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.cloud.gateway.rsocket.server.GatewayExchange;
|
||||
import org.springframework.cloud.gateway.rsocket.server.GatewayFilter;
|
||||
import org.springframework.cloud.gateway.rsocket.core.GatewayExchange;
|
||||
import org.springframework.cloud.gateway.rsocket.core.GatewayFilter;
|
||||
import org.springframework.cloud.gateway.rsocket.support.AsyncPredicate;
|
||||
import org.springframework.cloud.gateway.rsocket.support.Metadata;
|
||||
import org.springframework.core.Ordered;
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.cloud.gateway.rsocket.server.GatewayExchange;
|
||||
import org.springframework.cloud.gateway.rsocket.core.GatewayExchange;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
|
||||
@@ -30,7 +30,7 @@ import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.cloud.gateway.rsocket.autoconfigure.GatewayRSocketProperties;
|
||||
import org.springframework.cloud.gateway.rsocket.metrics.MicrometerResponderRSocket;
|
||||
import org.springframework.cloud.gateway.rsocket.server.GatewayRSocket;
|
||||
import org.springframework.cloud.gateway.rsocket.core.GatewayRSocket;
|
||||
import org.springframework.cloud.gateway.rsocket.support.Metadata;
|
||||
|
||||
public class GatewaySocketAcceptor implements SocketAcceptor {
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.boot.test.context.runner.ReactiveWebApplicationContex
|
||||
import org.springframework.cloud.gateway.rsocket.registry.Registry;
|
||||
import org.springframework.cloud.gateway.rsocket.registry.RegistryRoutes;
|
||||
import org.springframework.cloud.gateway.rsocket.registry.RegistrySocketAcceptorFilter;
|
||||
import org.springframework.cloud.gateway.rsocket.server.GatewayServerRSocketFactoryCustomizer;
|
||||
import org.springframework.cloud.gateway.rsocket.core.GatewayServerRSocketFactoryCustomizer;
|
||||
import org.springframework.cloud.gateway.rsocket.socketacceptor.GatewaySocketAcceptor;
|
||||
import org.springframework.cloud.gateway.rsocket.socketacceptor.SocketAcceptorPredicate;
|
||||
import org.springframework.cloud.gateway.rsocket.socketacceptor.SocketAcceptorPredicateFilter;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.gateway.rsocket.server;
|
||||
package org.springframework.cloud.gateway.rsocket.core;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@@ -26,7 +26,7 @@ import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.rsocket.RSocketProperties;
|
||||
import org.springframework.boot.rsocket.netty.NettyRSocketBootstrap;
|
||||
import org.springframework.boot.rsocket.server.RSocketServerBootstrap;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.cloud.gateway.rsocket.test.PingPongApp;
|
||||
@@ -56,7 +56,7 @@ public class GatewayRSocketIntegrationTests {
|
||||
private PingPongApp.MySocketAcceptorFilter mySocketAcceptorFilter;
|
||||
|
||||
@Autowired
|
||||
private NettyRSocketBootstrap server;
|
||||
private RSocketServerBootstrap server;
|
||||
|
||||
@BeforeClass
|
||||
public static void init() {
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.gateway.rsocket.server;
|
||||
package org.springframework.cloud.gateway.rsocket.core;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
@@ -31,7 +31,7 @@ import org.junit.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.cloud.gateway.rsocket.autoconfigure.GatewayRSocketProperties;
|
||||
import org.springframework.cloud.gateway.rsocket.server.GatewayRSocket;
|
||||
import org.springframework.cloud.gateway.rsocket.core.GatewayRSocket;
|
||||
import org.springframework.cloud.gateway.rsocket.support.Metadata;
|
||||
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
@@ -42,9 +42,9 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.cloud.gateway.rsocket.server.GatewayExchange;
|
||||
import org.springframework.cloud.gateway.rsocket.server.GatewayFilter;
|
||||
import org.springframework.cloud.gateway.rsocket.server.GatewayFilterChain;
|
||||
import org.springframework.cloud.gateway.rsocket.core.GatewayExchange;
|
||||
import org.springframework.cloud.gateway.rsocket.core.GatewayFilter;
|
||||
import org.springframework.cloud.gateway.rsocket.core.GatewayFilterChain;
|
||||
import org.springframework.cloud.gateway.rsocket.socketacceptor.SocketAcceptorExchange;
|
||||
import org.springframework.cloud.gateway.rsocket.socketacceptor.SocketAcceptorFilter;
|
||||
import org.springframework.cloud.gateway.rsocket.socketacceptor.SocketAcceptorFilterChain;
|
||||
@@ -140,39 +140,33 @@ public class PingPongApp {
|
||||
DefaultPayload.create(EMPTY_BUFFER, announcementMetadata))
|
||||
.addClientPlugin(interceptor)
|
||||
.transport(TcpClientTransport.create(gatewayPort)) // proxy
|
||||
.start().flatMapMany(socket -> {
|
||||
Flux<String> pong = socket.requestChannel(
|
||||
Flux.interval(Duration.ofSeconds(1)).map(i -> {
|
||||
ByteBuf data = ByteBufUtil.writeUtf8(
|
||||
ByteBufAllocator.DEFAULT, "ping" + id);
|
||||
ByteBuf routingMetadata = Metadata.from("pong")
|
||||
.encode();
|
||||
return DefaultPayload.create(data, routingMetadata);
|
||||
}).onBackpressureDrop(payload -> log.debug(
|
||||
"Dropped payload " + payload.getDataUtf8())) // this
|
||||
// is
|
||||
// needed
|
||||
// in
|
||||
// case
|
||||
// pong
|
||||
// is
|
||||
// not
|
||||
// available
|
||||
// yet
|
||||
).map(Payload::getDataUtf8).doOnNext(str -> {
|
||||
int received = pongsReceived.incrementAndGet();
|
||||
log.info("received " + str + "(" + received + ") in Ping"
|
||||
+ id);
|
||||
}).doFinally(signal -> socket.dispose());
|
||||
if (take != null) {
|
||||
return pong.take(take);
|
||||
}
|
||||
return pong;
|
||||
});
|
||||
.start().flatMapMany(socket -> doPing(take, socket));
|
||||
|
||||
pongFlux.subscribe();
|
||||
}
|
||||
|
||||
Publisher<? extends String> doPing(Integer take, RSocket socket) {
|
||||
Flux<String> pong = socket.requestChannel(
|
||||
Flux.interval(Duration.ofSeconds(1)).map(i -> {
|
||||
ByteBuf data = ByteBufUtil.writeUtf8(
|
||||
ByteBufAllocator.DEFAULT, "ping" + id);
|
||||
ByteBuf routingMetadata = Metadata.from("pong")
|
||||
.encode();
|
||||
return DefaultPayload.create(data, routingMetadata);
|
||||
// onBackpressue is needed in case pong is not available yet
|
||||
}).onBackpressureDrop(payload -> log.debug(
|
||||
"Dropped payload " + payload.getDataUtf8()))
|
||||
).map(Payload::getDataUtf8).doOnNext(str -> {
|
||||
int received = pongsReceived.incrementAndGet();
|
||||
log.info("received " + str + "(" + received + ") in Ping"
|
||||
+ id);
|
||||
}).doFinally(signal -> socket.dispose());
|
||||
if (take != null) {
|
||||
return pong.take(take);
|
||||
}
|
||||
return pong;
|
||||
}
|
||||
|
||||
public Flux<String> getPongFlux() {
|
||||
return pongFlux;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user