rehasher

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	RehashKeepDevice           = "rehash_keep_device"
	RehashDisconnectDevice     = "rehash_disconnect_device"
	RehashDisconnectAllCounter = "rehash_disconnect_all_count"
	RehashTimestamp            = "rehash_timestamp"
	RehashDurationMilliseconds = "rehash_duration_ms"

	ReasonLabel = "reason"

	DisconnectAllServiceDiscoveryError       = "sd_error"
	DisconnectAllServiceDiscoveryStopped     = "sd_stopped"
	DisconnectAllServiceDiscoveryNoInstances = "sd_no_instances"
)
View Source
const (
	RehashError         = "rehash-error"
	RehashOtherInstance = "rehash-other-instance"

	ServiceDiscoveryError       = "service-discovery-error"
	ServiceDiscoveryStopped     = "service-discovery-stopped"
	ServiceDiscoveryNoInstances = "service-discovery-no-instances"
)

Variables

This section is empty.

Functions

func Metrics

func Metrics() []xmetrics.Metric

Metrics is the device module function that adds default device metrics

func New

func New(connector device.Connector, options ...Option) monitor.Listener

New creates a monitor Listener which will rehash and disconnect devices in response to service discovery events. This function panics if the connector is nil or if no IsRegistered strategy is configured.

If the returned listener encounters any service discovery error, all devices are disconnected. Otherwise, the IsRegistered strategy is used to determine which devices should still be connected to the Connector. Devices that hash to instances not registered in this environment are disconnected.

Types

type Option

type Option func(*rehasher)

Option is a configuration option for a rehasher

func WithAccessorFactory

func WithAccessorFactory(af service.AccessorFactory) Option

WithAccessorFactory configures a rehasher with a specific factory for service.Accessor objects. If af is nil, the default accessor factory is used.

func WithIsRegistered

func WithIsRegistered(f func(string) bool) Option

WithIsRegistered configures a rehasher with a strategy for determining if a discovered service instance is registered as this process. There is no default.

func WithLogger

func WithLogger(l log.Logger) Option

WithLogger configures a rehasher with a logger, using the default logger if l is nil.

func WithMetricsProvider

func WithMetricsProvider(p provider.Provider) Option

WithMetricsProvider configures a metrics subsystem the resulting rehasher will use to track things. A nil provider passed to this option means to discard all metrics.

Jump to

Keyboard shortcuts

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