ringpopprovider

package
v1.2.11-prerelease4 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BootstrapMode

type BootstrapMode int

BootstrapMode is an enum type for ringpop bootstrap mode

const (
	// BootstrapModeNone represents a bootstrap mode set to nothing or invalid
	BootstrapModeNone BootstrapMode = iota
	// BootstrapModeFile represents a file-based bootstrap mode
	BootstrapModeFile
	// BootstrapModeHosts represents a list of hosts passed in the configuration
	BootstrapModeHosts
	// BootstrapModeCustom represents a custom bootstrap mode
	BootstrapModeCustom
	// BootstrapModeDNS represents a list of hosts passed in the configuration
	// to be resolved, and the resulting addresses are used for bootstrap
	BootstrapModeDNS
	// BootstrapModeDNSSRV represents a list of DNS hosts passed in the configuration
	// to resolve secondary addresses that DNS SRV record would return resulting in
	// a host list that will contain multiple dynamic addresses and their unique ports
	BootstrapModeDNSSRV
)

func (*BootstrapMode) UnmarshalYAML

func (m *BootstrapMode) UnmarshalYAML(
	unmarshal func(interface{}) error,
) error

UnmarshalYAML is called by the yaml package to convert the config YAML into a BootstrapMode.

type Config

type Config struct {
	// Name to be used in ringpop advertisement
	Name string `yaml:"name" validate:"nonzero"`
	// BootstrapMode is a enum that defines the ringpop bootstrap method, currently supports: hosts, files, custom, dns, and dns-srv
	BootstrapMode BootstrapMode `yaml:"bootstrapMode"`
	// BootstrapHosts is a list of seed hosts to be used for ringpop bootstrap
	BootstrapHosts []string `yaml:"bootstrapHosts"`
	// BootstrapFile is the file path to be used for ringpop bootstrap
	BootstrapFile string `yaml:"bootstrapFile"`
	// MaxJoinDuration is the max wait time to join the ring
	MaxJoinDuration time.Duration `yaml:"maxJoinDuration"`
	// Custom discovery provider, cannot be specified through yaml
	DiscoveryProvider discovery.DiscoverProvider `yaml:"-"`
}

Config contains the ringpop config items

type Provider

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

Provider use ringpop to announce membership changes

func New

func New(
	service string,
	config *Config,
	channel tchannel.Channel,
	portMap membership.PortMap,
	logger log.Logger,
) (*Provider, error)

func NewRingpopProvider

func NewRingpopProvider(
	service string,
	rp *ringpop.Ringpop,
	portMap membership.PortMap,
	bootstrapOpts *swim.BootstrapOptions,
	logger log.Logger,
) *Provider

NewRingpopProvider sets up ringpop based peer provider

func (*Provider) GetMembers

func (r *Provider) GetMembers(service string) ([]membership.HostInfo, error)

GetMembers returns all hosts with a specified role value

func (*Provider) HandleEvent

func (r *Provider) HandleEvent(
	event events.Event,
)

HandleEvent handles updates from ringpop

func (*Provider) SelfEvict

func (r *Provider) SelfEvict() error

func (*Provider) Start

func (r *Provider) Start()

Start starts ringpop

func (*Provider) Stop

func (r *Provider) Stop()

Stop stops ringpop

func (*Provider) Subscribe

func (r *Provider) Subscribe(name string, notifyChannel chan<- *membership.ChangedEvent) error

Subscribe allows to be subscribed for ring changes

func (*Provider) WhoAmI

func (r *Provider) WhoAmI() (membership.HostInfo, error)

WhoAmI returns address of this instance

Jump to

Keyboard shortcuts

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