integration

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ControlAdvance advances the time ticker (see cmd/set.go)
	ControlAdvance = 1
	// ControlExit immediately exists the loop
	ControlExit = 2
	// ControlFinish finishes the loop
	ControlFinish = 3
)

Variables

This section is empty.

Functions

func CompareDestinationIdentifyingEquality

func CompareDestinationIdentifyingEquality(ca *IPVSConfig, a *Destination, cb *IPVSConfig, b *Destination) (bool, error)

CompareDestinationIdentifyingEquality compares two destinations within IPVSConfig if Host and post are equal

func CompareDestinationsEquality

func CompareDestinationsEquality(ca *IPVSConfig, a *Destination, cb *IPVSConfig, b *Destination, opts ApplyOpts) (bool, error)

CompareDestinationsEquality compares two destinations within a IPVSConfig if ports, hosts and the rest are equal

func CompareServicesEquality

func CompareServicesEquality(ca *IPVSConfig, a *Service, cb *IPVSConfig, b *Service) (bool, error)

CompareServicesEquality for Service does a complete compare. it applies config defaults

func CompareServicesIdentifyingEquality

func CompareServicesIdentifyingEquality(ca *IPVSConfig, a *Service, cb *IPVSConfig, b *Service) (bool, error)

CompareServicesIdentifyingEquality for Service compares service address including defaults

func MakeAdressStringFromIpvsDestination

func MakeAdressStringFromIpvsDestination(dest *ipvs.Destination) string

MakeAdressStringFromIpvsDestination creates a model-valid address string from an ipvs.Destination entry.

func MakeAdressStringFromIpvsService

func MakeAdressStringFromIpvsService(service *ipvs.Service) string

MakeAdressStringFromIpvsService creates a model-valid address string from an ipvs.Service entry.

Types

type ApplyActionType

type ApplyActionType string

ApplyActionType is a mapped string to some action for the apply function

const (
	// ApplyActionAddService allows the addition of new services
	ApplyActionAddService ApplyActionType = "as"

	// ApplyActionUpdateService allows the update of existing services
	ApplyActionUpdateService ApplyActionType = "us"

	// ApplyActionDeleteService allows deletion of existing services
	ApplyActionDeleteService ApplyActionType = "ds"

	// ApplyActionAddDestination allows the addition of new destinations to existing services
	ApplyActionAddDestination ApplyActionType = "ad"

	// ApplyActionUpdateDestination allows for updates of existing destinations
	ApplyActionUpdateDestination ApplyActionType = "ud"

	// ApplyActionDeleteDestination allows for deleting of existing destinations
	ApplyActionDeleteDestination ApplyActionType = "dd"
)

type ApplyActions

type ApplyActions map[ApplyActionType]bool

ApplyActions maps actions to bools

func AllApplyActions added in v0.3.0

func AllApplyActions() ApplyActions

AllApplyActions provides the ApplyActions with all actions enabled

type ApplyOpts added in v0.2.0

type ApplyOpts struct {
	KeepWeights    bool
	AllowedActions ApplyActions
}

ApplyOpts is tthe options struct for the apply action

type ChangeSet

type ChangeSet struct {
	Items []interface{} `yaml:"items,omitempty"`
}

ChangeSet contains a number of change set items

func NewChangeSet

func NewChangeSet() *ChangeSet

NewChangeSet makes a new changeset

func (*ChangeSet) AddChange

func (cs *ChangeSet) AddChange(csi ChangeSetItem)

AddChange adds a new item to the changeset

type ChangeSetItem

type ChangeSetItem struct {
	Type        ChangeSetItemType `yaml:"type"`
	Description string
	Service     *Service     `yaml:"service,omitempty"`
	Destination *Destination `yaml:"destination,omitempty"`
}

ChangeSetItem ...

type ChangeSetItemType

type ChangeSetItemType string

ChangeSetItemType as type for const names of types of change set items

const (
	// AddService adds a new service
	AddService ChangeSetItemType = "add-service"

	// UpdateService edits an existing service
	UpdateService ChangeSetItemType = "update-service"

	// DeleteService deletes an existing service
	DeleteService ChangeSetItemType = "delete-service"

	// AddDestination adds a new destination to an existing service
	AddDestination ChangeSetItemType = "add-destination"

	// UpdateDestination edits an existing destination
	UpdateDestination ChangeSetItemType = "update-destination"

	// DeleteDestination deletes an existing destination
	DeleteDestination ChangeSetItemType = "delete-destination"
)

type ContinousControlCh

type ContinousControlCh chan int

ContinousControlCh is a signalling channel

type Defaults

type Defaults struct {
	Port      *int    `yaml:"port,omitempty"`    // default port
	Weight    *int    `yaml:"weight,omitempty"`  // default weight for weighted forwarders
	SchedName *string `yaml:"sched,omitempty"`   // default scheduler
	Forward   *string `yaml:"forward,omitempty"` // default forwards as string (direct, tunnel, nat)
}

Defaults contains default values for various model elements. If set here they can be omitted in Services or Destinations

type Destination

type Destination struct {
	Address string `yaml:"address"`
	Weight  int    `yaml:"weight,omitempty"`  // weight for weighted forwarders
	Forward string `yaml:"forward,omitempty"` // forwards as string (direct, tunnel, nat)
	// contains filtered or unexported fields
}

Destination models a real server behind a service

type IPVSApplyError

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

IPVSApplyError signal an error when applying a new configuration

func (*IPVSApplyError) Error

func (e *IPVSApplyError) Error() string

type IPVSConfig

type IPVSConfig struct {
	Defaults Defaults   `yaml:"defaults,omitempty"`
	Services []*Service `yaml:"services,omitempty"`
	// contains filtered or unexported fields
}

IPVSConfig is a single ipvs setup

func From added in v0.2.3

func From(c *IPVSConfig) *IPVSConfig

From creates a new IPSConfig from an existing one

func NewIPVSConfig added in v0.2.3

func NewIPVSConfig() *IPVSConfig

NewIPVSConfig creates a new IPVS configuration object with a default logger

func NewIPVSConfigWithLogger added in v0.2.3

func NewIPVSConfigWithLogger(l *log.Logger) *IPVSConfig

NewIPVSConfigWithLogger creates a new IPVS configuration object with a custom logger

func (*IPVSConfig) Apply

func (ipvsconfig *IPVSConfig) Apply(newconfig *IPVSConfig, opts ApplyOpts) error

Apply compares new config to current config, builds a changeset and applies the change set items within.

func (*IPVSConfig) ApplyChangeSet

func (ipvsconfig *IPVSConfig) ApplyChangeSet(newconfig *IPVSConfig, cs *ChangeSet, opts ApplyOpts) error

ApplyChangeSet takes a change set and applies all change items to the given IPVSConfig

func (*IPVSConfig) ChangeSet

func (ipvsconfig *IPVSConfig) ChangeSet(newconfig *IPVSConfig, opts ApplyOpts) (*ChangeSet, error)

ChangeSet compares current active configuration against newconfig and creates a change set containing all differences

func (*IPVSConfig) Get

func (ipvsconfig *IPVSConfig) Get() error

Get retrieves the current IPVC config with all services and destinations

func (*IPVSConfig) LocateServiceAndDestination

func (c *IPVSConfig) LocateServiceAndDestination(serviceHandle, destinationHandle string) (*Service, *Destination)

LocateServiceAndDestination returns a Service and Destination by their names

func (*IPVSConfig) NewIpvsDestinationStruct

func (c *IPVSConfig) NewIpvsDestinationStruct(destination *Destination) (*ipvs.Destination, error)

NewIpvsDestinationStruct creates a single new ipvs.Destination struct from model integration.Service

func (*IPVSConfig) NewIpvsDestinationsStruct

func (c *IPVSConfig) NewIpvsDestinationsStruct(s *Service) ([]*ipvs.Destination, error)

NewIpvsDestinationsStruct creates a new ipvs.Destination struct array from model integration.Service

func (*IPVSConfig) NewIpvsServiceStruct

func (c *IPVSConfig) NewIpvsServiceStruct(s *Service) (*ipvs.Service, error)

NewIpvsServiceStruct creates a new ipvs.service struct from model integration.Service

func (*IPVSConfig) ResolveParams

func (ipvsconfig *IPVSConfig) ResolveParams(rc dynp.ResolverChain) (*IPVSConfig, error)

ResolveParams walks over a complete IPVS configuration and resolves all dynamic parameters using the ResolverChain. It returns a copy of the configuration or an error

func (*IPVSConfig) SetWeight

func (ipvsconfig *IPVSConfig) SetWeight(serviceName, destinationName string, newWeight int) error

SetWeight sets the destination's weight to newWeight

func (*IPVSConfig) SetWeightContinuous

func (ipvsconfig *IPVSConfig) SetWeightContinuous(
	serviceName, destinationName string,
	toWeight int,
	amountOfTimeSecs int,
	cch ContinousControlCh) error

SetWeightContinuous sets the weight of a destination to a target value, within a given amount of time, controlled by a channel.

func (*IPVSConfig) Validate

func (ipvsconfig *IPVSConfig) Validate() error

Validate checks ipvsconfig for structural errors

type IPVSHandleError

type IPVSHandleError struct{}

IPVSHandleError signals that we cannot obtain an ipvs handle

func (*IPVSHandleError) Error

func (e *IPVSHandleError) Error() string

type IPVSQueryError

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

IPVSQueryError signal an error when querying data

func (*IPVSQueryError) Error

func (e *IPVSQueryError) Error() string

type IPVSValidateError

type IPVSValidateError struct {
	What string
}

IPVSValidateError signal an error when validating a configuration

func (*IPVSValidateError) Error

func (e *IPVSValidateError) Error() string

type IPVSetError

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

IPVSetError signals an error when updating configuration

func (*IPVSetError) Error

func (e *IPVSetError) Error() string

type Service

type Service struct {
	Address      string         `yaml:"address"`
	SchedName    string         `yaml:"sched,omitempty"`
	Destinations []*Destination `yaml:"destinations,omitempty"`
	// contains filtered or unexported fields
}

Service describes an IPVS service entry

func (*Service) IsEqual

func (s *Service) IsEqual(b *Service) bool

IsEqual for Services returns true if both s and b point to the same address string (that includes the protocol)

Jump to

Keyboard shortcuts

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