client

package
v0.0.0-...-d4eddb9 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Provide

func Provide(
	addr, service, thisAddr string, priority, weight, reconnectAttempts int,
	interval time.Duration,
) error

Provide is a DEPRECATED method for making a connection to a skyapi instance. Use ProvideOpts instead

func ProvideOpts

func ProvideOpts(o Opts) error

ProvideOpts uses the given Opts value to connect to a skyapi instance and declare a service being provided for. It blocks until disconnect or some other error.

Types

type Opts

type Opts struct {

	// Required. The address of the skyapi instance to connect to. Should be
	// "host:port" or a hostname that can be resolved via SRV lookup
	SkyAPIAddr string

	// Required. The name of the service this process is providing for
	Service string

	// Required. The address to advertise this process at. Can be either
	// "host:port" or ":port"
	ThisAddr string

	// Optional. A prefix that will be prepended to the hashed id that is created
	// for the domain. Useful for passing grouping information such as datacenter.
	Prefix string

	// Optional. The category this service falls under. Defaults to the skyapi
	// server's global default, usually "services"
	Category string

	// Optional. The priority and weight values which will be stored along with
	// this entry, and which will be returned in SRV requests to the skyapi
	// server. Defaults to 1 and 100, respectively
	Priority, Weight int

	// Optional. Setting to a positive number will cause the connection to
	// attempt to be remade up to that number of times on a disconnect. After
	// that many failed attempts an error is returned. If 0 an error is returned
	// on the first disconnect. If set to a negative number reconnect attempts
	// will continue forever
	ReconnectAttempts int

	// Optional. The interval to ping the server at in order to ensure the
	// connection is still alive. Defaults to 10 seconds.
	Interval time.Duration

	// Optional. If set, can be later closed by another process to indicate that
	// the client should stop advertising and close. A nil error will be
	// returned by the ProvideOpts method in this case.
	StopCh chan struct{}

	Resolver Resolver
}

Opts represent a set of options which can be passed into ProvideOpts. Some are required to be filled in and are marked as such. The rest have defaults listed in their descriptions

type Resolver

type Resolver interface {
	// Takes in some arbitrary name or hostname and returns an address for it.
	// Must be able to handle the given string already being an address.
	Resolve(string) (string, error)
}

Resolver is used to resolve arbitrary names of services to a single address, possibly selected out of many addresses. An address consists of "host:port".

Jump to

Keyboard shortcuts

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