2020-03-30 14:54:04 +02:00
|
|
|
package traffic
|
|
|
|
|
|
|
|
|
|
import (
|
2020-03-30 16:10:07 +02:00
|
|
|
"fmt"
|
|
|
|
|
|
2020-03-30 14:54:04 +02:00
|
|
|
"github.com/miekg/dns"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// See https://github.com/grpc/grpc/blob/master/doc/service_config.md for the fields in this proto.
|
|
|
|
|
// We encode it as json and return it in a TXT field.
|
2020-03-30 16:10:07 +02:00
|
|
|
// TOOD(miek): balancer name should not be hardcoded
|
|
|
|
|
var lbTXT = `grpc_config=[{"serviceConfig":{"loadBalancingConfig":[{"eds_experimental":{"Cluster": "xds", "EDSServiceName":"%s", "BalancerName":"xds"}}]}}]`
|
2020-03-30 14:54:04 +02:00
|
|
|
|
2020-03-30 16:10:07 +02:00
|
|
|
func txt(z, cluster string) []dns.RR {
|
2020-03-30 14:54:04 +02:00
|
|
|
return []dns.RR{&dns.TXT{
|
|
|
|
|
Hdr: dns.RR_Header{Name: z, Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: 5},
|
2020-03-30 16:10:07 +02:00
|
|
|
Txt: []string{fmt.Sprintf(lbTXT, cluster)},
|
2020-03-30 14:54:04 +02:00
|
|
|
}}
|
|
|
|
|
}
|