Skip to content

Commit 5a90fd2

Browse files
committed
Add starters back into project.
This commit brings the starters back into the project. Signed-off-by: onobc <chris.bono@gmail.com>
1 parent 826c6b1 commit 5a90fd2

File tree

100 files changed

+9959
-4
lines changed

Some content is hidden

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

100 files changed

+9959
-4
lines changed

pom.xml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,21 @@
1414
<description>Building gRPC applications with Spring Boot</description>
1515

1616
<modules>
17+
<!-- Spring gRPC modules -->
1718
<module>spring-grpc-build-dependencies</module>
18-
<module>spring-grpc-docs</module>
19-
<module>spring-grpc-dependencies</module>
2019
<module>spring-grpc-core</module>
21-
<!-- <module>samples</module>-->
20+
<module>spring-grpc-dependencies</module>
21+
<module>spring-grpc-docs</module>
22+
<!-- <module>samples</module>,-->
23+
24+
<!-- Spring Boot modules -->
25+
<module>spring-grpc-client-spring-boot-autoconfigure</module>
26+
<module>spring-grpc-client-spring-boot-starter</module>
27+
<module>spring-grpc-server-spring-boot-autoconfigure</module>
28+
<module>spring-grpc-server-spring-boot-starter</module>
29+
<module>spring-grpc-server-web-spring-boot-starter</module>
30+
<module>spring-grpc-spring-boot-starter</module>
31+
<module>spring-grpc-test-spring-boot-autoconfigure</module>
2232
</modules>
2333

2434
<organization>
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>org.springframework.grpc</groupId>
8+
<artifactId>spring-grpc</artifactId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
</parent>
11+
<artifactId>spring-grpc-client-spring-boot-autoconfigure</artifactId>
12+
<packaging>jar</packaging>
13+
<name>Spring gRPC Client Auto Configuration</name>
14+
<description>Spring gRPC Client Auto Configuration</description>
15+
<url>https://github.com/spring-projects/spring-grpc</url>
16+
17+
<scm>
18+
<url>https://github.com/spring-projects/spring-grpc</url>
19+
<connection>git://github.com/spring-projects/spring-grpc.git</connection>
20+
<developerConnection>git@github.com:spring-projects/spring-grpc.git</developerConnection>
21+
</scm>
22+
23+
<dependencyManagement>
24+
<dependencies>
25+
<dependency>
26+
<groupId>org.springframework.boot</groupId>
27+
<artifactId>spring-boot-dependencies</artifactId>
28+
<version>${spring-boot.version}</version>
29+
<type>pom</type>
30+
<scope>import</scope>
31+
</dependency>
32+
</dependencies>
33+
</dependencyManagement>
34+
35+
<dependencies>
36+
<!-- NOTE: The dependencies are grouped / ordered intentionally to match the -->
37+
<!-- order they will be when in build.gradle in Spring Boot. -->
38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.springframework.grpc</groupId>
44+
<artifactId>spring-grpc-core</artifactId>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>com.fasterxml.jackson.core</groupId>
49+
<artifactId>jackson-annotations</artifactId>
50+
<optional>true</optional>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>org.springframework.boot</groupId>
55+
<artifactId>spring-boot-autoconfigure</artifactId>
56+
<optional>true</optional>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.springframework.boot</groupId>
60+
<artifactId>spring-boot-autoconfigure-processor</artifactId>
61+
<optional>true</optional>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.springframework.boot</groupId>
65+
<artifactId>spring-boot-actuator</artifactId>
66+
<optional>true</optional>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.springframework.boot</groupId>
70+
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
71+
<optional>true</optional>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.springframework.boot</groupId>
75+
<artifactId>spring-boot-configuration-processor</artifactId>
76+
<optional>true</optional>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.springframework.boot</groupId>
80+
<artifactId>spring-boot-health</artifactId>
81+
<optional>true</optional>
82+
</dependency>
83+
<dependency>
84+
<groupId>org.springframework.boot</groupId>
85+
<artifactId>spring-boot-micrometer-observation</artifactId>
86+
<optional>true</optional>
87+
</dependency>
88+
<dependency>
89+
<groupId>org.springframework.boot</groupId>
90+
<artifactId>spring-boot-security</artifactId>
91+
<optional>true</optional>
92+
</dependency>
93+
<dependency>
94+
<groupId>org.springframework.boot</groupId>
95+
<artifactId>spring-boot-security-oauth2-client</artifactId>
96+
<optional>true</optional>
97+
</dependency>
98+
<dependency>
99+
<groupId>org.springframework.boot</groupId>
100+
<artifactId>spring-boot-security-oauth2-resource-server</artifactId>
101+
<optional>true</optional>
102+
</dependency>
103+
104+
<dependency>
105+
<groupId>io.grpc</groupId>
106+
<artifactId>grpc-servlet-jakarta</artifactId>
107+
<optional>true</optional>
108+
</dependency>
109+
<dependency>
110+
<groupId>io.grpc</groupId>
111+
<artifactId>grpc-stub</artifactId>
112+
<optional>true</optional>
113+
</dependency>
114+
<dependency>
115+
<groupId>io.grpc</groupId>
116+
<artifactId>grpc-netty</artifactId>
117+
<optional>true</optional>
118+
</dependency>
119+
<dependency>
120+
<groupId>io.grpc</groupId>
121+
<artifactId>grpc-netty-shaded</artifactId>
122+
<optional>true</optional>
123+
</dependency>
124+
<dependency>
125+
<groupId>io.grpc</groupId>
126+
<artifactId>grpc-inprocess</artifactId>
127+
<optional>true</optional>
128+
</dependency>
129+
<dependency>
130+
<groupId>io.grpc</groupId>
131+
<artifactId>grpc-kotlin-stub</artifactId>
132+
<optional>true</optional>
133+
<exclusions>
134+
<exclusion>
135+
<groupId>javax.annotation</groupId>
136+
<artifactId>javax.annotation-api</artifactId>
137+
</exclusion>
138+
</exclusions>
139+
</dependency>
140+
<dependency>
141+
<groupId>io.micrometer</groupId>
142+
<artifactId>micrometer-core</artifactId>
143+
<optional>true</optional>
144+
</dependency>
145+
<dependency>
146+
<groupId>io.netty</groupId>
147+
<artifactId>netty-transport-native-epoll</artifactId>
148+
<optional>true</optional>
149+
</dependency>
150+
<dependency>
151+
<groupId>io.projectreactor</groupId>
152+
<artifactId>reactor-core</artifactId>
153+
<optional>true</optional>
154+
</dependency>
155+
<dependency>
156+
<groupId>jakarta.servlet</groupId>
157+
<artifactId>jakarta.servlet-api</artifactId>
158+
<optional>true</optional>
159+
</dependency>
160+
161+
<dependency>
162+
<groupId>org.springframework</groupId>
163+
<artifactId>spring-web</artifactId>
164+
<optional>true</optional>
165+
</dependency>
166+
<dependency>
167+
<groupId>org.springframework.security</groupId>
168+
<artifactId>spring-security-config</artifactId>
169+
<optional>true</optional>
170+
</dependency>
171+
<dependency>
172+
<groupId>org.springframework.security</groupId>
173+
<artifactId>spring-security-oauth2-client</artifactId>
174+
<optional>true</optional>
175+
</dependency>
176+
<dependency>
177+
<groupId>org.springframework.security</groupId>
178+
<artifactId>spring-security-oauth2-resource-server</artifactId>
179+
<optional>true</optional>
180+
</dependency>
181+
<dependency>
182+
<groupId>org.springframework.security</groupId>
183+
<artifactId>spring-security-oauth2-jose</artifactId>
184+
<optional>true</optional>
185+
</dependency>
186+
<dependency>
187+
<groupId>org.springframework.security</groupId>
188+
<artifactId>spring-security-web</artifactId>
189+
<optional>true</optional>
190+
</dependency>
191+
192+
<!-- test dependencies -->
193+
<dependency>
194+
<groupId>org.springframework.boot</groupId>
195+
<artifactId>spring-boot-starter-test</artifactId>
196+
<scope>test</scope>
197+
</dependency>
198+
</dependencies>
199+
200+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.grpc.client.autoconfigure;
18+
19+
import java.util.ArrayList;
20+
import java.util.Collections;
21+
import java.util.List;
22+
23+
import org.springframework.boot.util.LambdaSafe;
24+
import org.springframework.grpc.client.GrpcChannelBuilderCustomizer;
25+
26+
import io.grpc.ManagedChannelBuilder;
27+
28+
/**
29+
* Invokes the available {@link GrpcChannelBuilderCustomizer} instances for a given
30+
* {@link ManagedChannelBuilder}.
31+
*
32+
* @author Chris Bono
33+
*/
34+
class ChannelBuilderCustomizers {
35+
36+
private final List<GrpcChannelBuilderCustomizer<?>> customizers;
37+
38+
ChannelBuilderCustomizers(List<? extends GrpcChannelBuilderCustomizer<?>> customizers) {
39+
this.customizers = (customizers != null) ? new ArrayList<>(customizers) : Collections.emptyList();
40+
}
41+
42+
/**
43+
* Customize the specified {@link ManagedChannelBuilder}. Locates all
44+
* {@link GrpcChannelBuilderCustomizer} beans able to handle the specified instance
45+
* and invoke {@link GrpcChannelBuilderCustomizer#customize} on them.
46+
* @param <T> the type of channel builder
47+
* @param authority the target authority of the channel
48+
* @param channelBuilder the builder to customize
49+
* @return the customized builder
50+
*/
51+
@SuppressWarnings("unchecked")
52+
<T extends ManagedChannelBuilder<?>> T customize(String authority, T channelBuilder) {
53+
LambdaSafe.callbacks(GrpcChannelBuilderCustomizer.class, this.customizers, channelBuilder)
54+
.withLogger(ChannelBuilderCustomizers.class)
55+
.invoke((customizer) -> customizer.customize(authority, channelBuilder));
56+
return channelBuilder;
57+
}
58+
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.grpc.client.autoconfigure;
18+
19+
import java.time.Duration;
20+
import java.util.Map;
21+
import java.util.concurrent.TimeUnit;
22+
import java.util.function.BiConsumer;
23+
import java.util.function.Consumer;
24+
25+
import org.springframework.boot.context.properties.PropertyMapper;
26+
import org.springframework.boot.grpc.client.autoconfigure.GrpcClientProperties.ChannelConfig;
27+
import org.springframework.grpc.client.GrpcChannelBuilderCustomizer;
28+
import org.springframework.grpc.client.interceptor.DefaultDeadlineSetupClientInterceptor;
29+
import org.springframework.util.unit.DataSize;
30+
31+
import io.grpc.ManagedChannelBuilder;
32+
33+
/**
34+
* A {@link GrpcChannelBuilderCustomizer} that maps {@link GrpcClientProperties client
35+
* properties} to a channel builder.
36+
*
37+
* @param <T> the type of the builder
38+
* @author David Syer
39+
* @author Chris Bono
40+
*/
41+
class ClientPropertiesChannelBuilderCustomizer<T extends ManagedChannelBuilder<T>>
42+
implements GrpcChannelBuilderCustomizer<T> {
43+
44+
private final GrpcClientProperties properties;
45+
46+
ClientPropertiesChannelBuilderCustomizer(GrpcClientProperties properties) {
47+
this.properties = properties;
48+
}
49+
50+
@Override
51+
public void customize(String authority, T builder) {
52+
ChannelConfig channel = this.properties.getChannel(authority);
53+
PropertyMapper mapper = PropertyMapper.get();
54+
mapper.from(channel.getUserAgent()).to(builder::userAgent);
55+
if (!authority.startsWith("unix:") && !authority.startsWith("in-process:")) {
56+
mapper.from(channel.getDefaultLoadBalancingPolicy()).to(builder::defaultLoadBalancingPolicy);
57+
}
58+
mapper.from(channel.getMaxInboundMessageSize()).asInt(DataSize::toBytes).to(builder::maxInboundMessageSize);
59+
mapper.from(channel.getMaxInboundMetadataSize()).asInt(DataSize::toBytes).to(builder::maxInboundMetadataSize);
60+
mapper.from(channel.getKeepAliveTime()).to(durationProperty(builder::keepAliveTime));
61+
mapper.from(channel.getKeepAliveTimeout()).to(durationProperty(builder::keepAliveTimeout));
62+
mapper.from(channel.getIdleTimeout()).to(durationProperty(builder::idleTimeout));
63+
mapper.from(channel.isKeepAliveWithoutCalls()).to(builder::keepAliveWithoutCalls);
64+
Map<String, Object> defaultServiceConfig = channel.extractServiceConfig();
65+
if (channel.getHealth().isEnabled()) {
66+
String serviceNameToCheck = (channel.getHealth().getServiceName() != null)
67+
? channel.getHealth().getServiceName() : "";
68+
defaultServiceConfig.put("healthCheckConfig", Map.of("serviceName", serviceNameToCheck));
69+
}
70+
if (!defaultServiceConfig.isEmpty()) {
71+
builder.defaultServiceConfig(defaultServiceConfig);
72+
}
73+
if (channel.getDefaultDeadline() != null && channel.getDefaultDeadline().toMillis() > 0L) {
74+
builder.intercept(new DefaultDeadlineSetupClientInterceptor(channel.getDefaultDeadline()));
75+
}
76+
}
77+
78+
Consumer<Duration> durationProperty(BiConsumer<Long, TimeUnit> setter) {
79+
return (duration) -> setter.accept(duration.toNanos(), TimeUnit.NANOSECONDS);
80+
}
81+
82+
}

0 commit comments

Comments
 (0)