sd

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registrar

type Registrar interface {
	Register(*Service)
	Deregister(*Service)
}

Registrar registers instance information to a service discovery system when an instance becomes alive and healthy, and deregisters that information when the service becomes unhealthy or goes away.

Registrar implementations exist for various service discovery systems. Note that identifying instance information (e.g. host:port) must be given via the concrete constructor; this interface merely signals lifecycle changes.

type Service

type Service struct {
	Key   string // unique key, e.g. "/service/foobar/1.2.3.4:8080"
	Value string // returned to subscribers, e.g. "http://1.2.3.4:8080"
	TTL   *TTLOption
}

Service holds the instance identifying data you want to publish to etcd. Key must be unique, and value is the string returned to subscribers, typically called the "instance" string in other parts of package sd.

func NewService

func NewService(key, value string) *Service

type TTLOption

type TTLOption struct {
	TTL time.Duration // e.g. time.Second * 10
	// contains filtered or unexported fields
}

TTLOption allow setting a key with a TTL. This option will be used by a loop goroutine which regularly refreshes the lease of the key.

func NewTTLOption

func NewTTLOption(heartbeat, ttl time.Duration) *TTLOption

NewTTLOption returns a TTLOption that contains proper TTL settings. Heartbeat is used to refresh the lease of the key periodically; its value should be at least 500ms. TTL defines the lease of the key; its value should be significantly greater than heartbeat.

Good default values might be 3s heartbeat, 10s TTL.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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