Skip to content

Commit c29f0e0

Browse files
committed
Initial server review
1 parent 444b1ad commit c29f0e0

15 files changed

+68
-1
lines changed

module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/ConditionalOnGrpcServerEnabled.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@
4242
@ConditionalOnProperty(prefix = "spring.grpc.server", name = "enabled", matchIfMissing = true)
4343
public @interface ConditionalOnGrpcServerEnabled {
4444

45+
// FIXME PW: rename? Not just enabled.
46+
4547
}

module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/ConditionalOnGrpcServletServer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,7 @@
4747
matchIfMissing = true)
4848
public @interface ConditionalOnGrpcServletServer {
4949

50+
// FIXME PW: Can we merge ConditionalOnGrpcNativeServer,
51+
// ConditionalOnGrpcServerEnabled and this with an enum attribute?
52+
5053
}

module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/DefaultServerFactoryPropertyMapper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
*/
3737
class DefaultServerFactoryPropertyMapper<T extends ServerBuilder<T>> {
3838

39-
final GrpcServerProperties properties;
39+
// FIXME PW: Might be able to simplify to reduce number of subclasses
40+
41+
final GrpcServerProperties properties; // FIXME PW private?
4042

4143
DefaultServerFactoryPropertyMapper(GrpcServerProperties properties) {
4244
this.properties = properties;
@@ -58,7 +60,9 @@ void customizeServerBuilder(T serverBuilder) {
5860
* @param mapper the property mapper
5961
*/
6062
void customizeKeepAlive(T serverBuilder, PropertyMapper mapper) {
63+
// FIXME PW: private?
6164
GrpcServerProperties.KeepAlive keepAliveProps = this.properties.getKeepAlive();
65+
// FIXME PW: nit - mapper -> map
6266
mapper.from(keepAliveProps.getTime()).to(durationProperty(serverBuilder::keepAliveTime));
6367
mapper.from(keepAliveProps.getTimeout()).to(durationProperty(serverBuilder::keepAliveTimeout));
6468
mapper.from(keepAliveProps.getMaxIdle()).to(durationProperty(serverBuilder::maxConnectionIdle));
@@ -74,6 +78,7 @@ void customizeKeepAlive(T serverBuilder, PropertyMapper mapper) {
7478
* @param mapper the property mapper
7579
*/
7680
void customizeInboundLimits(T serverBuilder, PropertyMapper mapper) {
81+
// FIXME PW: private?
7782
mapper.from(this.properties.getMaxInboundMessageSize())
7883
.asInt(DataSize::toBytes)
7984
.to(serverBuilder::maxInboundMessageSize);

module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/GrpcServerExecutorProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
public interface GrpcServerExecutorProvider {
2222

23+
// FIXME PW: Doc comment
24+
// FIXME PW: Functional interface?
25+
2326
/**
2427
* Returns a {@link Executor} for the gRPC server, if it needs tio be customized.
2528
* @return the executor to use for the gRPC server

module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/GrpcServerFactoryConfigurations.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ NettyGrpcServerFactory nettyGrpcServerFactory(GrpcServerProperties properties,
125125
KeyManagerFactory keyManager = null;
126126
TrustManagerFactory trustManager = null;
127127
if (properties.getSsl().isEnabled()) {
128+
// FIXME PW: looks similar to code above. Extract?
128129
String bundleName = properties.getSsl().getBundle();
129130
Assert.notNull(bundleName, () -> "SSL bundleName must not be null");
130131
SslBundle bundle = bundles.getBundle(bundleName);

module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/GrpcServerFactoryCustomizer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
public interface GrpcServerFactoryCustomizer {
2222

23+
// FIXME PW: Doc comment
24+
// FIXME PW: Functional interface?
25+
2326
/**
2427
* Customize the given {@link GrpcServerFactory}.
2528
* @param serverFactory the server factory to customize

module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/GrpcServerObservationAutoConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
@ConditionalOnProperty(name = "spring.grpc.server.observation.enabled", havingValue = "true", matchIfMissing = true)
4848
public final class GrpcServerObservationAutoConfiguration {
4949

50+
// FIXME PW: Observation direction (same as client)
51+
5052
@Bean
5153
@Order(0)
5254
@GlobalServerInterceptor

module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/GrpcServerProperties.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public class GrpcServerProperties {
5050
*/
5151
private int port = GrpcUtils.DEFAULT_PORT;
5252

53+
// FIXME PW: check that metadata works for defaults
54+
5355
/**
5456
* Maximum time to wait for the server to gracefully shutdown. When the value is
5557
* negative, the server waits forever. When the value is 0, the server will force
@@ -70,6 +72,8 @@ public class GrpcServerProperties {
7072
@DataSizeUnit(DataUnit.BYTES)
7173
private DataSize maxInboundMetadataSize = DataSize.ofBytes(8192);
7274

75+
// FIXME PW: nit drop default in doc comment.
76+
7377
private final Health health = new Health();
7478

7579
private final KeepAlive keepAlive = new KeepAlive();
@@ -82,14 +86,19 @@ public class GrpcServerProperties {
8286
*/
8387
@Nullable private String address;
8488

89+
// FIXME PW: private @Nullable (sweep code)
90+
8591
public String getAddress() {
92+
// FIXME PW: make anemic
8693
return (this.address != null) ? this.address : this.host + ":" + this.port;
8794
}
8895

8996
public void setAddress(String address) {
9097
this.address = address;
9198
}
9299

100+
// FIXME PW: all privates to top
101+
93102
private final Ssl ssl = new Ssl();
94103

95104
public Ssl getSsl() {
@@ -101,20 +110,25 @@ public String getHost() {
101110
}
102111

103112
public void setHost(String host) {
113+
// FIXME PW: should probably check when accessing not settings
114+
// FIXME PW: nit use Assert.state
104115
if (this.address != null) {
105116
throw new IllegalStateException("Cannot set host when address is already set");
106117
}
107118
this.host = host;
108119
}
109120

110121
public int getPort() {
122+
// FIXME PW: make anemic
111123
if (this.address != null) {
112124
return GrpcUtils.getPort(this.address);
113125
}
114126
return this.port;
115127
}
116128

117129
public void setPort(int port) {
130+
// FIXME PW: should probably check when accessing not settings
131+
// FIXME PW: nit use Assert.state
118132
if (this.address != null) {
119133
throw new IllegalStateException("Cannot set port when address is already set");
120134
}
@@ -180,19 +194,26 @@ public ActuatorAdapt getActuator() {
180194

181195
}
182196

197+
// FIXME PW: nit, rename to Actuator move under Health
198+
// FIXME PW: need to review actuator integration
199+
183200
public static class ActuatorAdapt {
184201

185202
/**
186203
* Whether to adapt Actuator health indicators into gRPC health checks.
187204
*/
188205
private Boolean enabled = true;
189206

207+
// FIXME PW: Boolean or boolean?
208+
190209
/**
191210
* Whether to update the overall gRPC server health (the '' service) with the
192211
* aggregate status of the configured health indicators.
193212
*/
194213
private Boolean updateOverallHealth = true;
195214

215+
// FIXME PW: Boolean or boolean?
216+
196217
/**
197218
* How often to update the health status.
198219
*/
@@ -273,6 +294,8 @@ public static class KeepAlive {
273294
@DurationUnit(ChronoUnit.SECONDS)
274295
private @Nullable Duration maxIdle = null;
275296

297+
// FIXME PW: nit, not '= null' (sweep code)
298+
276299
/**
277300
* Maximum time a connection may exist before being gracefully terminated (default
278301
* infinite).
@@ -298,6 +321,8 @@ public static class KeepAlive {
298321
*/
299322
private boolean permitWithoutCalls = false;
300323

324+
// FIXME PW: nit not = false
325+
301326
public @Nullable Duration getTime() {
302327
return this.time;
303328
}
@@ -364,6 +389,8 @@ public static class Ssl {
364389
*/
365390
private @Nullable Boolean enabled;
366391

392+
// FIXME PW: Check how enabled is used? Is enabled without bundle possible?
393+
367394
/**
368395
* Client authentication mode.
369396
*/
@@ -381,10 +408,12 @@ public static class Ssl {
381408
private boolean secure = true;
382409

383410
public boolean isEnabled() {
411+
// FIXME PW: Make anemic
384412
return (this.enabled != null) ? this.enabled : this.bundle != null;
385413
}
386414

387415
public void copyDefaultsFrom(Ssl config) {
416+
// FIXME PW: Check where used. Move out somewhere else?
388417
if (this.enabled == null) {
389418
this.enabled = config.enabled;
390419
}
@@ -437,6 +466,8 @@ public static class Inprocess {
437466
*/
438467
private @Nullable Boolean exclusive;
439468

469+
// FIXME PW: Boolean or boolean?
470+
440471
public @Nullable String getName() {
441472
return this.name;
442473
}

module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/ServerBuilderCustomizers.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
*/
3535
public class ServerBuilderCustomizers {
3636

37+
// FIXME PW: Package private?
38+
3739
private final List<ServerBuilderCustomizer<?>> customizers;
3840

3941
ServerBuilderCustomizers(List<? extends ServerBuilderCustomizer<?>> customizers) {

module/spring-boot-grpc-server/src/main/java/org/springframework/boot/grpc/server/autoconfigure/ServletEnvironmentPostProcessor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727
public class ServletEnvironmentPostProcessor implements EnvironmentPostProcessor {
2828

29+
// FIXME PW: Package private
30+
// FIXME PW: Unusual EPP. Not sure if there's a better way?
31+
2932
private static final boolean SERVLET_AVAILABLE = ClassUtils.isPresent("io.grpc.servlet.jakarta.GrpcServlet", null);
3033

3134
@Override

0 commit comments

Comments
 (0)