File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed
spring-grpc-core/src/main/java/org/springframework/grpc/client Expand file tree Collapse file tree 3 files changed +45
-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
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+ */
3241public 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 ;
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
23+ * authority.
24+ *
25+ * @author Dave Syer
26+ * @author Chris Bono
27+ * @see ManagedChannelBuilder
28+ */
2129@ FunctionalInterface
2230public 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}
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
23+ * authority.
24+ *
25+ * @author Dave Syer
26+ * @see ManagedChannelBuilder
27+ */
2128public 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}
You can’t perform that action at this time.
0 commit comments