@Override
    ImmutableSortedSet<Endpoint> onDnsRecords(List<DnsRecord> records, int ttl) throws Exception {
        final ImmutableSortedSet.Builder<Endpoint> builder = ImmutableSortedSet.naturalOrder();
        for (DnsRecord r : records) {
            if (!(r instanceof ByteArrayDnsRecord) || r.type() != DnsRecordType.TXT) {
                continue;
            }

            final byte[] content = ((ByteArrayDnsRecord) r).content();
            if (content.length == 0) { // Missing length octet
                warnInvalidRecord(DnsRecordType.TXT, content);
                continue;
            }

            final int txtLen = content[0] & 0xFF;
            if (txtLen == 0) { // Empty content
                continue;
            }

            if (content.length != txtLen + 1) { // Mismatching number of octets
                warnInvalidRecord(DnsRecordType.TXT, content);
                continue;
            }

            final byte[] txt = new byte[txtLen];
            System.arraycopy(content, 1, txt, 0, txtLen);

            final Endpoint endpoint;
            try {
                endpoint = mapping.apply(txt);
            } catch (Exception e) {
                warnInvalidRecord(DnsRecordType.TXT, content);
                continue;
            }

            if (endpoint != null) {
                builder.add(endpoint);
            }
        }

        final ImmutableSortedSet<Endpoint> endpoints = builder.build();
        logDnsResolutionResult(endpoints, ttl);
        return endpoints;
    }
Returns a new {@link DnsTextEndpointGroupBuilder} with
the specified hostname and {@link Function} mapping.

@param hostname the hostname to query DNS queries for
@param mapping the {@link Function} that maps the content of a {@code TXT} record into
               an {@link Endpoint}. The {@link Function} is expected to return {@code null}
               if the record contains unsupported content.
core/src/main/java/com/linecorp/armeria/client/endpoint/dns/DnsTextEndpointGroup.java