File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed
spring-grpc-core/src/main/java/org/springframework/grpc/client Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 2929import io .grpc .ManagedChannel ;
3030import io .grpc .ManagedChannelBuilder ;
3131
32+ /**
33+ * Default implementation of {@link GrpcChannelFactory} for creating and managing gRPC channels
34+ * <p>
35+ * Implements {@link DisposableBean} to shut down channels when no longer needed
36+ *
37+ * @author David Syer
38+ * @author Chris Bono
39+ */
3240public class DefaultGrpcChannelFactory implements GrpcChannelFactory , DisposableBean {
3341
3442 private final Map <String , ManagedChannelBuilder <?>> builders = new ConcurrentHashMap <>();
@@ -71,6 +79,13 @@ public ManagedChannelBuilder<?> createChannel(String authority) {
7179
7280 }
7381
82+ /**
83+ * Creates a new {@link ManagedChannelBuilder} instance for the given target path and credentials
84+ *
85+ * @param path the target path for the channel
86+ * @param creds the credentials for the channel
87+ * @return a new {@link ManagedChannelBuilder} for the given path and credentials
88+ */
7489 protected ManagedChannelBuilder <?> newChannel (String path , ChannelCredentials creds ) {
7590 return Grpc .newChannelBuilder (path , creds );
7691 }
@@ -82,6 +97,9 @@ public void destroy() {
8297 }
8398 }
8499
100+ /**
101+ * A {@link ManagedChannelBuilder} wrapper that ensures the created channel is disposed of when no longer needed
102+ */
85103 class DisposableChannelBuilder extends ForwardingChannelBuilder2 <DisposableChannelBuilder > {
86104
87105 private final ManagedChannelBuilder <?> delegate ;
Original file line number Diff line number Diff line change 1818
1919import io .grpc .ManagedChannelBuilder ;
2020
21+ /**
22+ * A functional interface for configuring a {@link ManagedChannelBuilder} for a specific authority
23+ *
24+ * @see ManagedChannelBuilder
25+ * @author Dave Syer
26+ * @author Chris Bono
27+ */
2128@ FunctionalInterface
2229public interface GrpcChannelConfigurer {
2330
31+ /**
32+ * Configures the given {@link ManagedChannelBuilder} for the specified authority
33+ *
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}
Original file line number Diff line number Diff line change 1818
1919import io .grpc .ManagedChannelBuilder ;
2020
21+ /**
22+ * Factory interface for creating {@link ManagedChannelBuilder} instances for a given authority
23+ *
24+ * @see ManagedChannelBuilder
25+ * @author Dave Syer
26+ */
2127public interface GrpcChannelFactory {
2228
29+ /**
30+ * Creates a {@link ManagedChannelBuilder} for the given authority
31+ *
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}
You can’t perform that action at this time.
0 commit comments