hostlist

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2019 License: Apache-2.0 Imports: 13 Imported by: 16

Documentation

Overview

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DNS record from which to resolve host names. Must include port suffix,
	// which will be attached to each host within the record.
	DNS string `yaml:"dns"`

	// Statically configured addresses. Must be in 'host:port' format.
	Static []string `yaml:"static"`

	// TTL defines how long resolved host lists are cached for.
	TTL time.Duration `yaml:"ttl"`
}

Config defines a list of hosts using either a DNS record or a static list of addresses. If present, a DNS record always takes precedence over a static list.

type List

type List interface {
	Resolve() stringset.Set
}

List defines a list of addresses which is subject to change.

func Fixture

func Fixture(addrs ...string) List

Fixture returns a static list of addrs for testing purposes.

func New

func New(config Config) (List, error)

New creates a new List.

An error is returned if a DNS record is supplied and resolves to an empty list of addresses.

If List is backed by DNS, it will be periodically refreshed (defined by TTL in config). If, after construction, there is an error resolving DNS, the latest successful snapshot is used. As such, Resolve never returns an empty set.

func StripLocal

func StripLocal(list List, port int) (List, error)

StripLocal wraps a List and filters out the local machine, if present. The local machine is identified by both its hostname and ip address, concatenated with port.

If the local machine is the only member of list, then Resolve returns an empty set.

Jump to

Keyboard shortcuts

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