Skip to content

Commit d352540

Browse files
api: Add more Javadoc for NameResolver.Listener2 interface (#12220)
1 parent 5a8326f commit d352540

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

api/src/main/java/io/grpc/NameResolver.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ public final void onAddresses(
239239
* {@link ResolutionResult#getAddressesOrError()} is empty, {@link #onError(Status)} will be
240240
* called.
241241
*
242+
* <p>Newer NameResolver implementations should prefer calling onResult2. This method exists to
243+
* facilitate older {@link Listener} implementations to migrate to {@link Listener2}.
244+
*
242245
* @param resolutionResult the resolved server addresses, attributes, and Service Config.
243246
* @since 1.21.0
244247
*/
@@ -248,16 +251,25 @@ public final void onAddresses(
248251
* Handles a name resolving error from the resolver. The listener is responsible for eventually
249252
* invoking {@link NameResolver#refresh()} to re-attempt resolution.
250253
*
254+
* <p>New NameResolver implementations should prefer calling onResult2 which will have the
255+
* address resolution error in {@link ResolutionResult}'s addressesOrError. This method exists
256+
* to facilitate older implementations using {@link Listener} to migrate to {@link Listener2}.
257+
*
251258
* @param error a non-OK status
252259
* @since 1.21.0
253260
*/
254261
@Override
255262
public abstract void onError(Status error);
256263

257264
/**
258-
* Handles updates on resolved addresses and attributes.
265+
* Handles updates on resolved addresses and attributes. Must be called from the same
266+
* {@link SynchronizationContext} available in {@link NameResolver.Args} that is passed
267+
* from the channel.
259268
*
260-
* @param resolutionResult the resolved server addresses, attributes, and Service Config.
269+
* @param resolutionResult the resolved server addresses or error in address resolution,
270+
* attributes, and Service Config or error
271+
* @return status indicating whether the resolutionResult was accepted by the listener,
272+
* typically the result from a load balancer.
261273
* @since 1.66
262274
*/
263275
public Status onResult2(ResolutionResult resolutionResult) {

0 commit comments

Comments
 (0)