discovery

package
v3.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSRVAddresses

func GetSRVAddresses(dnsName, dnsServer string) ([]string, error)

Given a DNS name return a list of addresses returned by the getting the SRV records from DNS for that name.

func NewLogWriter

func NewLogWriter(log logrus.FieldLogger) *io.PipeWriter

Types

type Consul

type Consul struct {
	// contains filtered or unexported fields
}

func (*Consul) Close

func (cs *Consul) Close(ctx context.Context) error

func (*Consul) GetPeers

func (cs *Consul) GetPeers(ctx context.Context) ([]Peer, error)

type ConsulConfig

type ConsulConfig struct {
	// This is the consul client config; typically created by calling api.DefaultConfig()
	ClientConfig *api.Config

	// The name of the catalog we should register under; should be common to all peers in the catalog
	CatalogName string

	// Information about this peer which should be shared with all other peers in the catalog
	Peer Peer

	// This is an address the will be registered with consul so it can preform liveliness checks
	LivelinessAddress string

	// A callback function which is called when the member list changes
	OnUpdate OnUpdateFunc

	// An interface through which logging will occur; usually *logrus.Entry
	Logger logrus.FieldLogger
}

type MemberList

type MemberList struct {
	// contains filtered or unexported fields
}

func (*MemberList) Close

func (m *MemberList) Close(ctx context.Context) error

func (*MemberList) GetPeers

func (m *MemberList) GetPeers(_ context.Context) ([]Peer, error)

type MemberListConfig

type MemberListConfig struct {
	// This is the address:port the member list protocol listen for other peers on.
	BindAddress string
	// This is the address:port the member list protocol will advertise to other peers. (Defaults to BindAddress)
	AdvertiseAddress string
	// Metadata about this peer which should be shared with other peers
	Peer Peer
	// A list of peers this member list instance can contact to find other peers.
	KnownPeers []string
	// A callback function which is called when the member list changes.
	OnUpdate OnUpdateFunc
	// If not nil, use this config instead of ml.DefaultLANConfig()
	MemberListConfig *ml.Config
	// An interface through which logging will occur; usually *logrus.Entry
	Logger logrus.FieldLogger
}

type Members

type Members interface {
	// Returns the peers currently registered
	GetPeers(context.Context) ([]Peer, error)
	// Removes our peer from the member list and closes all connections
	Close(context.Context) error
}

func NewConsul

func NewConsul(conf *ConsulConfig) (Members, error)

func NewMemberList

func NewMemberList(ctx context.Context, conf MemberListConfig) (Members, error)

type OnUpdateFunc

type OnUpdateFunc func([]Peer)

type Peer

type Peer struct {
	// An ID the uniquely identifies this peer
	ID string
	// The metadata associated with this peer
	Metadata []byte
	// Is true if this Peer refers to our instance
	IsSelf bool
}

Jump to

Keyboard shortcuts

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