models

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncryptedDataTypeAESCFB = "aes-cfb"
)
View Source
const (
	EtcdLinkDirectory = "/link"
)

Variables

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

Functions

This section is empty.

Types

type EncryptedData

type EncryptedData struct {
	Type string `json:"type"`
	Data string `json:"data"`
}

type EncryptedStorage

type EncryptedStorage interface {
	Encrypt(ctx context.Context, data any) (EncryptedData, error)
	Decrypt(ctx context.Context, data EncryptedData, v any) error
}

func NewEncryptedStorage

func NewEncryptedStorage(ctx context.Context, config config.Config) (EncryptedStorage, error)

type Endpoint

type Endpoint struct {
	ID string `json:"id"` // ID of this endpoint (starting with vip-)

	// Full IP with mask (i.e. 10.0.0.1/32)
	// Deprecated: The IP is now stored in the ARP Plugin config. This field is kept for backward compatibility
	IP string `json:"ip"`

	Checks              HealthChecks `json:"checks,omitempty"`     // Health check configured with this Endpoint
	HealthCheckInterval int          `json:"healthcheck_interval"` // Health check Intervals for this Endpoint

	Plugin       string          `json:"plugin,omitempty"`        // Plugin to use for this Endpoint
	PluginConfig json.RawMessage `json:"plugin_config,omitempty"` // Plugin configuration
}

Endpoint stores the configuration of an endpoint for one host

func (Endpoint) LogFields

func (i Endpoint) LogFields() logrus.Fields

ToLogrusFields returns a Logrus representation of an IP

func (Endpoint) ToAPIType

func (i Endpoint) ToAPIType() api.Endpoint
type EndpointLink struct {
	UpdatedAt time.Time `json:"updated_at"`
}

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

type Endpoints

type Endpoints []Endpoint

func (Endpoints) ToAPIType

func (e Endpoints) ToAPIType() []api.Endpoint

type EtcdStorage

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

func NewEtcdStorage

func NewEtcdStorage(config config.Config) EtcdStorage

func (EtcdStorage) AddEndpoint

func (e EtcdStorage) AddEndpoint(ctx context.Context, endpoint Endpoint) (Endpoint, error)

func (EtcdStorage) GetCurrentHost

func (e EtcdStorage) GetCurrentHost(ctx context.Context) (Host, error)

func (EtcdStorage) GetEndpointHosts

func (e EtcdStorage) GetEndpointHosts(ctx context.Context, lockKey string) ([]string, error)

func (EtcdStorage) GetEndpoints

func (e EtcdStorage) GetEndpoints(ctx context.Context) (Endpoints, error)

func (EtcdStorage) LinkEndpointWithCurrentHost

func (e EtcdStorage) LinkEndpointWithCurrentHost(ctx context.Context, lockKey string) error

func (EtcdStorage) RemoveEndpoint

func (e EtcdStorage) RemoveEndpoint(ctx context.Context, id string) error

func (EtcdStorage) SaveHost

func (e EtcdStorage) SaveHost(ctx context.Context, host Host) error

func (EtcdStorage) UnlinkEndpointFromCurrentHost

func (e EtcdStorage) UnlinkEndpointFromCurrentHost(ctx context.Context, lockKey string) error

func (EtcdStorage) UpdateEndpoint

func (e EtcdStorage) UpdateEndpoint(ctx context.Context, endpoint Endpoint) error

type HealthCheck

type HealthCheck struct {
	Type api.HealthCheckType `json:"type"`
	Host string              `json:"host"`
	Port int                 `json:"port"`
}

func HealthCheckFromAPIType

func HealthCheckFromAPIType(h api.HealthCheck) HealthCheck

func (HealthCheck) Addr

func (h HealthCheck) Addr() string

func (HealthCheck) ToAPIType

func (h HealthCheck) ToAPIType() api.HealthCheck

func (HealthCheck) Validate

func (h HealthCheck) Validate(_ context.Context) error

type HealthChecks

type HealthChecks []HealthCheck

func HealthChecksFromAPIType

func HealthChecksFromAPIType(hs []api.HealthCheck) HealthChecks

func (HealthChecks) ToAPIType

func (h HealthChecks) ToAPIType() []api.HealthCheck

func (HealthChecks) Validate

func (h HealthChecks) Validate(ctx context.Context) error

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 Storage

type Storage interface {
	GetEndpoints(ctx context.Context) (Endpoints, error) // GetEndpoints configured for this host
	AddEndpoint(ctx context.Context, endpoint Endpoint) (Endpoint, error)
	UpdateEndpoint(ctx context.Context, endpoint Endpoint) error
	RemoveEndpoint(ctx context.Context, id string) error

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

	LinkEndpointWithCurrentHost(ctx context.Context, key string) error   // Link an Endpoint to the current host
	UnlinkEndpointFromCurrentHost(ctx context.Context, key string) error // Unlink an Endpoint from the current host
	GetEndpointHosts(ctx context.Context, key string) ([]string, error)  // List all hosts linked to the Endpoint
}

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