MCPcopy Create free account
hub / github.com/grpc/grpc-java / AbstractStub

Class AbstractStub

stub/src/main/java/io/grpc/stub/AbstractStub.java:53–282  ·  view source on GitHub ↗

Common base type for stub implementations. Stub configuration is immutable; changing the configuration returns a new stub with updated configuration. Changing the configuration is cheap and may be done before every RPC, such as would be common when using #withDeadlineAfter. Configuration

Source from the content-addressed store, hash-verified

51 * @param <S> the concrete type of this stub.
52 */
53@CheckReturnValue
54public abstract class AbstractStub<S extends AbstractStub<S>> {
55 private final Channel channel;
56 private final CallOptions callOptions;
57
58 /**
59 * Constructor for use by subclasses, with the default {@code CallOptions}.
60 *
61 * @since 1.0.0
62 * @param channel the channel that this stub will use to do communications
63 */
64 protected AbstractStub(Channel channel) {
65 this(channel, CallOptions.DEFAULT);
66 }
67
68 /**
69 * Constructor for use by subclasses.
70 *
71 * @since 1.0.0
72 * @param channel the channel that this stub will use to do communications
73 * @param callOptions the runtime call options to be applied to every call on this stub
74 */
75 protected AbstractStub(Channel channel, CallOptions callOptions) {
76 this.channel = checkNotNull(channel, "channel");
77 this.callOptions = checkNotNull(callOptions, "callOptions");
78 }
79
80 /**
81 * The underlying channel of the stub.
82 *
83 * @since 1.0.0
84 */
85 public final Channel getChannel() {
86 return channel;
87 }
88
89 /**
90 * The {@code CallOptions} of the stub.
91 *
92 * @since 1.0.0
93 */
94 public final CallOptions getCallOptions() {
95 return callOptions;
96 }
97
98 /**
99 * Returns a new stub with the given channel for the provided method configurations.
100 *
101 * @since 1.0.0
102 * @param channel the channel that this stub will use to do communications
103 * @param callOptions the runtime call options to be applied to every call on this stub
104 */
105 protected abstract S build(Channel channel, CallOptions callOptions);
106
107 /**
108 * Returns a new stub with the given channel for the provided method configurations.
109 *
110 * @since 1.26.0

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected