예제 #1
0
func newClient(timeout time.Duration) exchanger.Exchanger {
	clients := make([]exchanger.Exchanger, 2)
	for i, proto := range [...]string{"udp", "tcp"} { // See RFC5966
		clients[i] = &dns.Client{
			Net:          proto,
			DialTimeout:  timeout,
			ReadTimeout:  timeout,
			WriteTimeout: timeout,
		}
	}
	return exchanger.Decorate(
		exchanger.While(truncated, clients...),
		exchanger.Recursion(3, exchanger.Recurse),
		exchanger.ErrorLogging(logging.Error),
		exchanger.Instrumentation(logging.CurLog.NonMesosRecursed),
	)
}
예제 #2
0
func exchangers(timeout time.Duration, protos ...string) map[string]exchanger.Exchanger {
	exs := make(map[string]exchanger.Exchanger, len(protos))
	for _, proto := range protos {
		exs[proto] = exchanger.Decorate(
			&dns.Client{
				Net:          proto,
				DialTimeout:  timeout,
				ReadTimeout:  timeout,
				WriteTimeout: timeout,
			},
			exchanger.ErrorLogging(logging.Error),
			exchanger.Instrumentation(
				logging.CurLog.NonMesosForwarded,
				logging.CurLog.NonMesosSuccess,
				logging.CurLog.NonMesosFailed,
			),
		)
	}
	return exs
}