exchanger

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package exchanger provides DNS exchanger decorators and other utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Recurse

func Recurse(r *dns.Msg) string

Recurse is the default Mesos-DNS Recurser which returns an addr (host:port) only when the given dns.Msg doesn't contain authoritative answers and has at least one SOA record in its NS section.

Types

type Decorator

type Decorator func(Exchanger) Exchanger

A Decorator adds a layer of behaviour to a given Exchanger.

func ErrorLogging

func ErrorLogging(l *log.Logger) Decorator

ErrorLogging returns a Decorator which logs an Exchanger's errors to the given logger.

func Instrumentation

func Instrumentation(c logging.Counter) Decorator

Instrumentation returns a Decorator which instruments an Exchanger with the given counter.

func Recursion

func Recursion(max int, rec Recurser) Decorator

Recursion returns a Decorator which recurses until the given Recurser returns an empty string or max attempts have been reached.

type Exchanger

type Exchanger interface {
	// Exchange performs an synchronous query. It sends the message m to the address
	// contained in addr (host:port) and waits for a reply.
	Exchange(m *dns.Msg, addr string) (r *dns.Msg, rtt time.Duration, err error)
}

Exchanger is an interface capturing a dns.Client Exchange method.

func Decorate

func Decorate(ex Exchanger, ds ...Decorator) Exchanger

Decorate decorates an Exchanger with the given Decorators.

func While

func While(p Pred, exs ...Exchanger) Exchanger

While returns an Exchanger which attempts the given Exchangers while the given predicate function returns true for the returned dns.Msg, an error is returned, or all Exchangers are attempted, in which case the return values of the last one are returned.

type Func

type Func func(*dns.Msg, string) (*dns.Msg, time.Duration, error)

Func is a function type that implements the Exchanger interface.

func (Func) Exchange

func (f Func) Exchange(m *dns.Msg, addr string) (*dns.Msg, time.Duration, error)

Exchange implements the Exchanger interface.

type Pred

type Pred func(*dns.Msg) bool

Pred is a predicate function type for dns.Msgs.

type Recurser

type Recurser func(*dns.Msg) string

A Recurser returns the addr (host:port) of the next DNS server to recurse a Msg to. Empty returns signal that further recursion isn't possible or needed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL