Skip to content

Commit 50e2db6

Browse files
therepanicdsyer
authored andcommitted
Update JavaDocs for grpc-client classes
1 parent d61af1a commit 50e2db6

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

spring-grpc-core/src/main/java/org/springframework/grpc/client/DefaultGrpcChannelFactory.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@
2929
import io.grpc.ManagedChannel;
3030
import io.grpc.ManagedChannelBuilder;
3131

32+
/**
33+
* Default implementation of {@link GrpcChannelFactory} for creating and managing gRPC
34+
* channels.
35+
* <p>
36+
* Implements {@link DisposableBean} to shut down channels when no longer needed
37+
*
38+
* @author David Syer
39+
* @author Chris Bono
40+
*/
3241
public class DefaultGrpcChannelFactory implements GrpcChannelFactory, DisposableBean {
3342

3443
private final Map<String, ManagedChannelBuilder<?>> builders = new ConcurrentHashMap<>();
@@ -71,6 +80,13 @@ public ManagedChannelBuilder<?> createChannel(String authority) {
7180

7281
}
7382

83+
/**
84+
* Creates a new {@link ManagedChannelBuilder} instance for the given target path and
85+
* credentials.
86+
* @param path the target path for the channel
87+
* @param creds the credentials for the channel
88+
* @return a new {@link ManagedChannelBuilder} for the given path and credentials
89+
*/
7490
protected ManagedChannelBuilder<?> newChannel(String path, ChannelCredentials creds) {
7591
return Grpc.newChannelBuilder(path, creds);
7692
}
@@ -82,6 +98,10 @@ public void destroy() {
8298
}
8399
}
84100

101+
/**
102+
* A {@link ManagedChannelBuilder} wrapper that ensures the created channel is
103+
* disposed of when no longer needed.
104+
*/
85105
class DisposableChannelBuilder extends ForwardingChannelBuilder2<DisposableChannelBuilder> {
86106

87107
private final ManagedChannelBuilder<?> delegate;

spring-grpc-core/src/main/java/org/springframework/grpc/client/GrpcChannelConfigurer.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,22 @@
1818

1919
import io.grpc.ManagedChannelBuilder;
2020

21+
/**
22+
* A functional interface for configuring a {@link ManagedChannelBuilder} for a specific
23+
* authority.
24+
*
25+
* @author Dave Syer
26+
* @author Chris Bono
27+
* @see ManagedChannelBuilder
28+
*/
2129
@FunctionalInterface
2230
public interface GrpcChannelConfigurer {
2331

32+
/**
33+
* Configures the given {@link ManagedChannelBuilder} for the specified authority.
34+
* @param authority the target authority for the channel
35+
* @param builder the builder to configure
36+
*/
2437
void configure(String authority, ManagedChannelBuilder<?> builder);
2538

2639
}

spring-grpc-core/src/main/java/org/springframework/grpc/client/GrpcChannelFactory.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,20 @@
1818

1919
import io.grpc.ManagedChannelBuilder;
2020

21+
/**
22+
* Factory interface for creating {@link ManagedChannelBuilder} instances for a given
23+
* authority.
24+
*
25+
* @author Dave Syer
26+
* @see ManagedChannelBuilder
27+
*/
2128
public interface GrpcChannelFactory {
2229

30+
/**
31+
* Creates a {@link ManagedChannelBuilder} for the given authority.
32+
* @param authority the target authority for the channel
33+
* @return a {@link ManagedChannelBuilder} configured for the given authority
34+
*/
2335
ManagedChannelBuilder<?> createChannel(String authority);
2436

2537
}

0 commit comments

Comments
 (0)