models

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EtcdLinkDirectory = "/link"
)

Variables

View Source
var (
	ErrIPAlreadyPresent = errors.New("IP already present")
	ErrHostNotFound     = errors.New("host not found")
)

Functions

func NewEtcdStorage

func NewEtcdStorage(config config.Config) etcdStorage

Types

type Healthcheck

type Healthcheck struct {
	Type HealthcheckType `json:"type"`
	Host string          `json:"host"`
	Port int             `json:"port"`
}

func (Healthcheck) Addr

func (h Healthcheck) Addr() string

type HealthcheckType

type HealthcheckType string
const (
	TCPHealthCheck HealthcheckType = "TCP"
)

type Host

type Host struct {
	Hostname string `json:"hostname"` // Hostname of this host
	LeaseID  int64  `json:"lease_id"` // LeaseID current lease ID of this host
	// DataVersion is the version number of how the data is stored in etcd for this host. This field is introduced in 2.0.0. But the data format version v0 correspond to the format before v1.9.0.
	DataVersion int `json:"data_version,omitempty"`
}

Host stores the host configuration. This is used by an host to retrieve his configuration after a restart.

type IP

type IP struct {
	ID                  string        `json:"id"`                   // ID of this Virtual IP (strarting with vip-)
	IP                  string        `json:"ip"`                   // Full IP with mask (i.e. 10.0.0.1/32)
	Status              string        `json:"status,omitempty"`     // Status of this VIP
	Checks              []Healthcheck `json:"checks,omitempty"`     // Healthcheck configured with this VIP
	HealthcheckInterval int           `json:"healthcheck_interval"` // HealthcheckIntevals for this VIP
}

IP stores the configuration of a virtual IP for one host

func (IP) StorableIP

func (i IP) StorableIP() string

StorableIP transforms the IP to a string that is compatible with ETCD key naming rules

func (IP) ToLogrusFields

func (i IP) ToLogrusFields() logrus.Fields

ToLogrusFields returns a Logrus representation of an IP

type IPLink struct {
	UpdatedAt time.Time `json:"updated_at"`
}

IPLink is the structure stored when an IP is linked to an Host

type Storage

type Storage interface {
	GetIPs(context.Context) ([]IP, error) // GetIPs configured for this host
	AddIP(context.Context, IP) (IP, error)
	UpdateIP(ctx context.Context, ip IP) error
	RemoveIP(context.Context, string) error

	GetCurrentHost(context.Context) (Host, error) // Get host configuration for the current host
	SaveHost(context.Context, Host) error         // Save host modifications

	LinkIPWithCurrentHost(context.Context, IP) error   // Link an IP to the current host
	UnlinkIPFromCurrentHost(context.Context, IP) error // Unlink an IP from the current host
	GetIPHosts(context.Context, IP) ([]string, error)  // List all hosts linked to the IP
}

Storage engine needed for the LinK persistent memory

Directories

Path Synopsis
Package modelsmock is a generated GoMock package.
Package modelsmock is a generated GoMock package.

Jump to

Keyboard shortcuts

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