Documentation ¶
Overview ¶
Package naming is a library that converts a target to one or multiple network addresses. A target can be actively watched for updates.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrWatcherClosed = errors.New("watcher closed")
)
Functions ¶
func Register ¶
Register makes a resolver available by the provided name. If a resolver is registered twice or if it is nil, it will panic.
func SetDefaultScheme ¶
func SetDefaultScheme(s string)
SetDefaultScheme defines the default scheme to use when the URI does not have it
Types ¶
type Operation ¶
type Operation uint8
Operation defines the corresponding operations for a name resolution change.
type Resolver ¶
type Resolver interface { // Resolve creates a Watcher for target. Resolve(target string) (Watcher, error) }
Resolver creates a Watcher for a target to track its resolution changes.
func DNS ¶
DNS creates a DNS Resolver that can resolve DNS names, and create watchers that poll the DNS server using the frequency set by freq or the default frequency defined by defaultFreq.
func Disco ¶
Disco creates a Disco Resolver that uses service discovery to find available instances. It also creates watchers that listen to service discovery updates
func Passthrough ¶
Passthrough returns a resolver that defer the name resolution to the client
type Update ¶
type Update struct { // Op indicates the operation of the update. Op Operation // Addr is the updated address. It is empty string if there is no address update. Addr string // Metadata is the updated metadata. It is nil if there is no metadata update. // Metadata is not required for a custom naming implementation. Metadata interface{} }
Update defines a name resolution update. Notice that it is not valid having both empty string Addr and nil Metadata in an Update.
type Watcher ¶
type Watcher interface { // Next blocks until an update or error happens. It may return one or more // updates. The first call should get the full set of the results. It should // return an error if and only if Watcher cannot recover. Next() ([]*Update, error) // Close closes the Watcher. Close() error }
Watcher watches for the updates on the specified target.