mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-20 06:29:16 +00:00
Polish
This commit is contained in:
+2
-2
@@ -182,7 +182,7 @@ public record ServiceConfig(@Nullable List<LoadBalancingConfig> loadbalancing, @
|
||||
* @param outOfBandReportingPeriod load reporting interval to request from the
|
||||
* server
|
||||
* @param enableOutOfBandLoadReport whether to enable out-of-band utilization
|
||||
* reporting collection from the endpoints
|
||||
* reporting collections from the endpoints
|
||||
* @param weightUpdatePeriod how often endpoint weights are recalculated
|
||||
* @param errorUtilizationPenalty multiplier used to adjust endpoint weights with
|
||||
* the error rate calculated as eps/qps
|
||||
@@ -327,7 +327,7 @@ public record ServiceConfig(@Nullable List<LoadBalancingConfig> loadbalancing, @
|
||||
* @param maxBackoff maximum exponential backoff
|
||||
* @param backoffMultiplier exponential backoff multiplier
|
||||
* @param perAttemptReceiveTimeout per-attempt receive timeout
|
||||
* @param retryableStatusCodes status codes which may be retried
|
||||
* @param retryableStatusCodes status codes that may be retried
|
||||
*/
|
||||
public record RetryPolicy(Integer maxAttempts, Duration initialBackoff, Duration maxBackoff,
|
||||
Double backoffMultiplier, Duration perAttemptReceiveTimeout, Set<Status.Code> retryableStatusCodes) {
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ import org.springframework.util.ObjectUtils;
|
||||
*/
|
||||
public class GrpcServletRegistration extends DynamicRegistrationBean<Dynamic> {
|
||||
|
||||
private static Log logger = LogFactory.getLog(GrpcServletRegistration.class);
|
||||
private static final Log logger = LogFactory.getLog(GrpcServletRegistration.class);
|
||||
|
||||
private final GrpcServlet servlet;
|
||||
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ record NettyAddress(@Nullable Transport transport, @Nullable InetAddress address
|
||||
@Nullable String domainSocketPath) {
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
public String toString() {
|
||||
Transport transport = (this.transport != null) ? this.transport : deduceTransport();
|
||||
return switch (transport) {
|
||||
case TCP -> tcpAddress();
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ class AutoConfiguredHealthCheckedGrpcComponents implements HealthCheckedGrpcComp
|
||||
/**
|
||||
* Create a new {@link AutoConfiguredHealthCheckedGrpcComponents} instance.
|
||||
* @param applicationContext the application context used to check for override beans
|
||||
* @param properties the grpc server health properties
|
||||
* @param properties the gRPC server health properties
|
||||
*/
|
||||
AutoConfiguredHealthCheckedGrpcComponents(ApplicationContext applicationContext,
|
||||
GrpcServerHealthProperties properties) {
|
||||
|
||||
+2
-2
@@ -113,8 +113,8 @@ public final class GrpcServerHealthAutoConfiguration {
|
||||
reactiveHealthContributorRegistry.getIfAvailable(), VALIDATE_MEMBERSHIP_PROPERTY,
|
||||
(members) -> properties.getService().forEach((serviceName, service) -> {
|
||||
String property = "spring.grpc.server.health.service." + serviceName;
|
||||
members.member(property + ".include".formatted(serviceName), service.getInclude());
|
||||
members.member(property + ".exclude".formatted(serviceName), service.getExclude());
|
||||
members.member(property + ".include", service.getInclude());
|
||||
members.member(property + ".exclude", service.getExclude());
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ class GrpcDisableCsrfHttpConfigurer extends AbstractHttpConfigurer<GrpcDisableCs
|
||||
|
||||
static class GrpcCsrfRequestMatcher implements RequestMatcher {
|
||||
|
||||
static GrpcCsrfRequestMatcher INSTANCE = new GrpcCsrfRequestMatcher();
|
||||
static final GrpcCsrfRequestMatcher INSTANCE = new GrpcCsrfRequestMatcher();
|
||||
|
||||
@Override
|
||||
public boolean matches(HttpServletRequest request) {
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ public final class GrpcRequest {
|
||||
}
|
||||
|
||||
private boolean isExcluded(String service) {
|
||||
return !this.excludes.stream().anyMatch((candidate) -> candidate.equals(service));
|
||||
return this.excludes.stream().noneMatch((candidate) -> candidate.equals(service));
|
||||
}
|
||||
|
||||
private String getPath(String service) {
|
||||
|
||||
+2
-2
@@ -110,7 +110,7 @@ public final class GrpcRequest {
|
||||
this.delegate = createDelegate(context.get());
|
||||
}
|
||||
|
||||
private @Nullable RequestMatcher createDelegate(GrpcServiceDiscoverer grpcServiceDiscoverer) {
|
||||
private RequestMatcher createDelegate(GrpcServiceDiscoverer grpcServiceDiscoverer) {
|
||||
List<RequestMatcher> delegateMatchers = getDelegateMatchers(grpcServiceDiscoverer);
|
||||
return (!CollectionUtils.isEmpty(delegateMatchers)) ? new OrRequestMatcher(delegateMatchers)
|
||||
: EMPTY_MATCHER;
|
||||
@@ -125,7 +125,7 @@ public final class GrpcRequest {
|
||||
}
|
||||
|
||||
private boolean isExcluded(String service) {
|
||||
return !this.excludes.stream().anyMatch((candidate) -> candidate.equals(service));
|
||||
return this.excludes.stream().noneMatch((candidate) -> candidate.equals(service));
|
||||
}
|
||||
|
||||
private String getPath(String service) {
|
||||
|
||||
+8
-8
@@ -44,11 +44,11 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class GrpcServerHealth {
|
||||
|
||||
private HealthContributorRegistry registry;
|
||||
private final HealthContributorRegistry registry;
|
||||
|
||||
private @Nullable ReactiveHealthContributorRegistry fallbackRegistry;
|
||||
private final @Nullable ReactiveHealthContributorRegistry fallbackRegistry;
|
||||
|
||||
private HealthCheckedGrpcComponents components;
|
||||
private final HealthCheckedGrpcComponents components;
|
||||
|
||||
/**
|
||||
* Create a new {@link GrpcServerHealth} instance.
|
||||
@@ -69,16 +69,16 @@ public class GrpcServerHealth {
|
||||
update(manager::setStatus);
|
||||
}
|
||||
|
||||
public void update(BiConsumer<String, ServingStatus> updator) {
|
||||
public void update(BiConsumer<String, ServingStatus> updater) {
|
||||
Cache cache = new Cache();
|
||||
HealthCheckedGrpcComponent serverComponent = this.components.getServer();
|
||||
if (serverComponent != null) {
|
||||
updator.accept("", getServingStatus(cache, serverComponent));
|
||||
updater.accept("", getServingStatus(cache, serverComponent));
|
||||
}
|
||||
for (String serviceName : this.components.getServiceNames()) {
|
||||
HealthCheckedGrpcComponent serviceComponent = this.components.getService(serviceName);
|
||||
if (!serviceName.isEmpty() && serviceComponent != null) {
|
||||
updator.accept(serviceName, getServingStatus(cache, serviceComponent));
|
||||
updater.accept(serviceName, getServingStatus(cache, serviceComponent));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,11 +109,11 @@ public class GrpcServerHealth {
|
||||
}
|
||||
}
|
||||
|
||||
class Cache {
|
||||
static class Cache {
|
||||
|
||||
private final Map<String, Health> health = new HashMap<>();
|
||||
|
||||
Health getHealth(String name, HealthIndicator indicator) {
|
||||
@Nullable Health getHealth(String name, HealthIndicator indicator) {
|
||||
return this.health.computeIfAbsent(name, (key) -> indicator.health(false));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user