Skip to content

Commit 8c07e10

Browse files
committed
Adopt Reactor Netty 0.8.11.RELEASE
1 parent 8c76bc2 commit 8c07e10

File tree

55 files changed

+1922
-1585
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1922
-1585
lines changed

cloudfoundry-client-reactor/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<scope>test</scope>
6767
</dependency>
6868
<dependency>
69-
<groupId>io.projectreactor.ipc</groupId>
69+
<groupId>io.projectreactor.netty</groupId>
7070
<artifactId>reactor-netty</artifactId>
7171
</dependency>
7272
<dependency>

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/AbstractRootProvider.java

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@
1616

1717
package org.cloudfoundry.reactor;
1818

19+
import org.cloudfoundry.reactor.util.JsonCodec;
20+
import org.cloudfoundry.reactor.util.Operator;
21+
import org.cloudfoundry.reactor.util.OperatorContext;
22+
import org.cloudfoundry.reactor.util.UserAgent;
1923
import org.immutables.value.Value;
2024
import org.springframework.web.util.UriComponents;
2125
import org.springframework.web.util.UriComponentsBuilder;
26+
27+
import io.netty.handler.codec.http.HttpHeaders;
2228
import reactor.core.publisher.Mono;
29+
import reactor.netty.http.client.HttpClient;
2330

2431
import java.util.Optional;
2532
import java.util.regex.Matcher;
@@ -41,19 +48,19 @@ public final void checkForValidApiHost() {
4148
Matcher matcher = HOSTNAME_PATTERN.matcher(getApiHost());
4249

4350
if (!matcher.matches()) {
44-
throw new IllegalArgumentException(String.format("API hostname %s is not correctly formatted (e.g. 'api.local.pcfdev.io')", getApiHost()));
51+
throw new IllegalArgumentException(String.format("API hostname %s is not correctly formatted (e.g. 'api.local.pcfdev.io')",
52+
getApiHost()));
4553
}
4654
}
4755

4856
/**
49-
* The hostname of the API root. Typically something like {@code api.run.pivotal.io}.
57+
* The hostname of the API root. Typically something like {@code api.run.pivotal.io}.
5058
*/
5159
public abstract String getApiHost();
5260

5361
@Override
5462
public final Mono<String> getRoot(ConnectionContext connectionContext) {
55-
Mono<String> cached = doGetRoot(connectionContext)
56-
.delayUntil(uri -> trust(uri.getHost(), uri.getPort(), connectionContext))
63+
Mono<String> cached = doGetRoot(connectionContext).delayUntil(uri -> trust(uri.getHost(), uri.getPort(), connectionContext))
5764
.map(UriComponents::toUriString);
5865

5966
return connectionContext.getCacheDuration()
@@ -63,8 +70,7 @@ public final Mono<String> getRoot(ConnectionContext connectionContext) {
6370

6471
@Override
6572
public final Mono<String> getRoot(String key, ConnectionContext connectionContext) {
66-
Mono<String> cached = doGetRoot(key, connectionContext)
67-
.delayUntil(uri -> trust(uri.getHost(), uri.getPort(), connectionContext))
73+
Mono<String> cached = doGetRoot(key, connectionContext).delayUntil(uri -> trust(uri.getHost(), uri.getPort(), connectionContext))
6874
.map(UriComponents::toUriString);
6975

7076
return connectionContext.getCacheDuration()
@@ -77,7 +83,9 @@ public final Mono<String> getRoot(String key, ConnectionContext connectionContex
7783
protected abstract Mono<UriComponents> doGetRoot(String key, ConnectionContext connectionContext);
7884

7985
protected final UriComponents getRoot() {
80-
UriComponentsBuilder builder = UriComponentsBuilder.newInstance().scheme("https").host(getApiHost());
86+
UriComponentsBuilder builder = UriComponentsBuilder.newInstance()
87+
.scheme("https")
88+
.host(getApiHost());
8189
getPort().ifPresent(builder::port);
8290

8391
return normalize(builder);
@@ -92,7 +100,8 @@ protected final UriComponents normalize(UriComponentsBuilder builder) {
92100
builder.port(getPort().orElse(DEFAULT_PORT));
93101
}
94102

95-
return builder.build().encode();
103+
return builder.build()
104+
.encode();
96105
}
97106

98107
/**
@@ -101,7 +110,7 @@ protected final UriComponents normalize(UriComponentsBuilder builder) {
101110
abstract Optional<Integer> getPort();
102111

103112
/**
104-
* Whether the connection to the root API should be secure (i.e. using HTTPS). Defaults to {@code true}.
113+
* Whether the connection to the root API should be secure (i.e. using HTTPS). Defaults to {@code true}.
105114
*/
106115
abstract Optional<Boolean> getSecure();
107116

@@ -117,4 +126,16 @@ private Mono<Void> trust(String host, int port, ConnectionContext connectionCont
117126
return connectionContext.trust(host, port);
118127
}
119128

129+
public Mono<Operator> createOperator(ConnectionContext connectionContext) {
130+
HttpClient httpClient = connectionContext.getHttpClient();
131+
return getRoot(connectionContext).map(root -> OperatorContext.of(connectionContext, root))
132+
.map(operatorContext -> new Operator(operatorContext, httpClient))
133+
.map(operator -> operator.headers(this::addHeaders));
134+
}
135+
136+
private void addHeaders(HttpHeaders httpHeaders) {
137+
UserAgent.setUserAgent(httpHeaders);
138+
JsonCodec.setDecodeHeaders(httpHeaders);
139+
}
140+
120141
}

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/ConnectionContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import com.fasterxml.jackson.databind.ObjectMapper;
2020
import reactor.core.publisher.Mono;
21-
import reactor.ipc.netty.http.client.HttpClient;
21+
import reactor.netty.http.client.HttpClient;
2222

2323
import java.time.Duration;
2424
import java.util.Optional;

0 commit comments

Comments
 (0)