Skip to content

Commit

Permalink
Implement ServiceDiscoverer#toString() for DefaultDnsServiceDiscove…
Browse files Browse the repository at this point in the history
…rer (#2149)

Motivation:

A `ServiceDiscoverer` returned from `DefaultDnsServiceDiscovererBuilder`
is an anonymous class without a proper name. To let users log what type
of `ServiceDiscoverer` they have a reference to, implement `toString()`.

Modifications:

- Implement `toString()` for `DnsClients`;

Result:

Users can log what `ServiceDiscoverer` they have reference to.
  • Loading branch information
idelpivnitskiy authored Mar 18, 2022
1 parent ce70bdd commit 6edc415
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public Completable onClose() {
public Publisher<Collection<ServiceDiscovererEvent<InetSocketAddress>>> discover(final String s) {
return dns.dnsSrvQuery(s);
}

@Override
public String toString() {
return "DefaultDnsServiceDiscoverer{recordTypes=[SRV]}";
}
};
}

Expand Down Expand Up @@ -105,6 +110,11 @@ public Publisher<Collection<ServiceDiscovererEvent<InetSocketAddress>>> discover
.map(events -> mapEventList(events,
inetAddress -> new InetSocketAddress(inetAddress, hostAndPort.port())));
}

@Override
public String toString() {
return "DefaultDnsServiceDiscoverer{recordTypes=[A,AAAA]}";
}
};
}

Expand Down

0 comments on commit 6edc415

Please sign in to comment.