1 /*
2 * Copyright 2022 The Netty Project
3 *
4 * The Netty Project licenses this file to you under the Apache License,
5 * version 2.0 (the "License"); you may not use this file except in compliance
6 * with the License. You may obtain a copy of the License at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15 */
16 package io.netty.resolver.dns;
17
18 import java.net.InetSocketAddress;
19
20 /**
21 * An infinite stream of DNS server addresses, that requests feedback to be returned to it.
22 *
23 * If query is successful timing information is provided, else a failure notification is given.
24 */
25 public interface DnsServerResponseFeedbackAddressStream extends DnsServerAddressStream {
26
27 /**
28 * A way to provide success feedback to {@link DnsServerAddressStream} so that {@link #next()} can be tuned
29 * to return the best performing DNS server address
30 *
31 * NOTE: This is called regardless of the RCode returned by the DNS server
32 *
33 * @param address The address returned by {@link #next()} that feedback needs to be applied to
34 * @param queryResponseTimeNanos The response time of a query against the given DNS server
35 */
36 void feedbackSuccess(InetSocketAddress address, long queryResponseTimeNanos);
37
38 /**
39 * A way to provide failure feedback to {@link DnsServerAddressStream} so that {@link #next()} cab be tuned
40 * to return the best performing DNS server address
41 *
42 * @param address The address returned by {@link #next()} that feedback needs to be applied to
43 * @param failureCause The reason the DNS query failed, can be used to penalize failures differently
44 * @param queryResponseTimeNanos The response time of a query against the given DNS server
45 */
46 void feedbackFailure(InetSocketAddress address, Throwable failureCause, long queryResponseTimeNanos);
47 }