Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterPrometheusExporter(ctx *Context)
- type Backend
- type BackendInfo
- type BackendOptions
- type Context
- func (ctx *Context) Close()
- func (ctx *Context) CompareWith(storeServices map[string]*ServiceConfig) *StoreSyncStatus
- func (ctx *Context) CreateBackend(vsID, rsID string, opts *BackendOptions) error
- func (ctx *Context) CreateService(vsID string, serviceConfig *ServiceConfig) error
- func (ctx *Context) GetBackend(vsID, rsID string) (*BackendInfo, error)
- func (ctx *Context) GetPoolForService(svc gnl2go.Service) (gnl2go.Pool, error)
- func (ctx *Context) GetService(vsID string) (*ServiceInfo, error)
- func (ctx *Context) ListServices() ([]string, error)
- func (ctx *Context) RemoveBackend(vsID, rsID string) (*BackendOptions, error)
- func (ctx *Context) RemoveService(vsID string) (*ServiceOptions, error)
- func (ctx *Context) SetStore(store *Store)
- func (ctx *Context) StoreExist() bool
- func (ctx *Context) Synchronize(storeServicesConfig map[string]*ServiceConfig) error
- func (ctx *Context) UpdateBackend(vsID, rsID string, weight int32) (int32, error)
- type ContextOptions
- type Exporter
- type Ipvs
- type Service
- func (vs *Service) BackendExist(rsID string) bool
- func (vs *Service) CalcServiceStat() *ServiceInfo
- func (vs *Service) Cleanup()
- func (vs *Service) CreateBackend(rsID string, opts *BackendOptions) error
- func (vs *Service) GetBackend(rsID string) (*Backend, bool)
- func (vs *Service) RemoveBackend(rsID string) (*BackendOptions, error)
- type ServiceConfig
- type ServiceInfo
- type ServiceOptions
- type Store
- type StoreSyncStatus
Constants ¶
const ( // Default - Set 0 weight to failed backend Default int16 = iota // ZeroToOne - Set weight 1 to all if all backends have StatusDown ZeroToOne )
Fallback options
Variables ¶
var ( ErrIpvsSyscallFailed = errors.New("error while calling into IPVS") ErrObjectExists = errors.New("specified object already exists") ErrObjectNotFound = errors.New("unable to locate specified object") ErrIncompatibleAFs = errors.New("incompatible address families") )
Possible runtime errors.
var ( ErrMissingEndpoint = errors.New("endpoint information is missing") ErrUnknownMethod = errors.New("specified forwarding method is unknown") ErrUnknownProtocol = errors.New("specified protocol is unknown") ErrUnknownFlag = errors.New("specified flag is unknown") ErrUnknownFallbackFlag = errors.New("specified fallback flag is unknown") )
Possible validation errors.
Functions ¶
func RegisterPrometheusExporter ¶
func RegisterPrometheusExporter(ctx *Context)
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend RS entity of gorb
func (*Backend) UpdateWeight ¶
UpdateWeight save new weight and return prev
type BackendInfo ¶
type BackendInfo struct { Options *BackendOptions `json:"options"` Metrics pulse.Metrics `json:"metrics"` }
BackendInfo contains information about backend options and pulse.
type BackendOptions ¶
type BackendOptions struct { Host string `json:"host" yaml:"host"` Port uint16 `json:"port" yaml:"port"` // contains filtered or unexported fields }
BackendOptions describe a virtual service backend.
func (*BackendOptions) CompareStoreOptions ¶
func (o *BackendOptions) CompareStoreOptions(options *BackendOptions) bool
func (*BackendOptions) Validate ¶
func (o *BackendOptions) Validate() error
Validate fills missing fields and validates backend configuration.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context abstacts away the underlying IPVS bindings implementation.
func NewContext ¶
func NewContext(options ContextOptions) (*Context, error)
NewContext creates a new Context and initializes IPVS.
func (*Context) CompareWith ¶
func (ctx *Context) CompareWith(storeServices map[string]*ServiceConfig) *StoreSyncStatus
func (*Context) CreateBackend ¶
func (ctx *Context) CreateBackend(vsID, rsID string, opts *BackendOptions) error
CreateBackend registers a new backend with a virtual service.
func (*Context) CreateService ¶
func (ctx *Context) CreateService(vsID string, serviceConfig *ServiceConfig) error
CreateService registers a new virtual service with IPVS.
func (*Context) GetBackend ¶
func (ctx *Context) GetBackend(vsID, rsID string) (*BackendInfo, error)
GetBackend returns information about a backend.
func (*Context) GetPoolForService ¶
ipvs.GetPoolForService() not works =( impement via iteration
func (*Context) GetService ¶
func (ctx *Context) GetService(vsID string) (*ServiceInfo, error)
GetService returns information about a virtual service.
func (*Context) ListServices ¶
ListServices returns a list of all registered services.
func (*Context) RemoveBackend ¶
func (ctx *Context) RemoveBackend(vsID, rsID string) (*BackendOptions, error)
RemoveBackend deregisters a backend.
func (*Context) RemoveService ¶
func (ctx *Context) RemoveService(vsID string) (*ServiceOptions, error)
RemoveService deregisters a virtual service.
func (*Context) Synchronize ¶
func (ctx *Context) Synchronize(storeServicesConfig map[string]*ServiceConfig) error
type ContextOptions ¶
type ContextOptions struct { Disco string Endpoints []net.IP Flush bool ListenPort uint16 VipInterface string }
ContextOptions configure Context behavior.
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
func NewExporter ¶
func (*Exporter) Collect ¶
func (e *Exporter) Collect(ch chan<- prometheus.Metric)
func (*Exporter) Describe ¶
func (e *Exporter) Describe(ch chan<- *prometheus.Desc)
type Ipvs ¶
type Ipvs interface { Init() error Exit() Flush() error AddService(vip string, port uint16, protocol uint16, sched string) error AddServiceWithFlags(vip string, port uint16, protocol uint16, sched string, flags []byte) error DelService(vip string, port uint16, protocol uint16) error AddDestPort(vip string, vport uint16, rip string, rport uint16, protocol uint16, weight int32, fwd uint32) error UpdateDestPort(vip string, vport uint16, rip string, rport uint16, protocol uint16, weight int32, fwd uint32) error DelDestPort(vip string, vport uint16, rip string, rport uint16, protocol uint16) error // Unforture not work =( // GetPoolForService(svc gnl2go.Service) (gnl2go.Pool, error) GetPools() ([]gnl2go.Pool, error) }
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service VS entity of gorb
func (*Service) BackendExist ¶
func (*Service) CalcServiceStat ¶
func (vs *Service) CalcServiceStat() *ServiceInfo
func (*Service) Cleanup ¶
func (vs *Service) Cleanup()
Cleanup remove service backends, gracefully stops backend monitoring
func (*Service) CreateBackend ¶
func (vs *Service) CreateBackend(rsID string, opts *BackendOptions) error
CreateBackend registers a new backend in the virtual service.
func (*Service) RemoveBackend ¶
func (vs *Service) RemoveBackend(rsID string) (*BackendOptions, error)
RemoveBackend deregister a backend in the virtual service.
type ServiceConfig ¶
type ServiceConfig struct { ServiceOptions *ServiceOptions `yaml:"service_options"` ServiceBackends map[string]*BackendOptions `yaml:"service_backends"` }
type ServiceInfo ¶
type ServiceInfo struct { Options *ServiceOptions `json:"options"` Health float64 `json:"health"` Backends []string `json:"backends"` BackendsCount uint16 `json:"backends_count"` FallBack string `json:"fallback"` }
ServiceInfo contains information about virtual service options, its backends and overall virtual service health.
type ServiceOptions ¶
type ServiceOptions struct { //service settings Host string `json:"host" yaml:"host"` Port uint16 `json:"port" yaml:"port"` Protocol string `json:"protocol" yaml:"protocol"` LbMethod string `json:"lb_method" yaml:"lb_method"` ShFlags string `json:"sh_flags" yaml:"sh_flags"` Persistent bool `json:"persistent" yaml:"persistent"` Fallback string `json:"fallback" yaml:"fallback"` // service backends settings FwdMethod string `json:"fwd_method" yaml:"fwd_method"` Pulse *pulse.Options `json:"pulse" yaml:"pulse"` MaxWeight int32 `json:"max_weight" yaml:"max_weight"` // contains filtered or unexported fields }
ServiceOptions describe a virtual service.
func (*ServiceOptions) CompareStoreOptions ¶
func (o *ServiceOptions) CompareStoreOptions(options *ServiceOptions) bool
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) StartSyncWithStore ¶
StartSyncWithStore synchronize gorb with store
func (*Store) StoreSyncStatus ¶
func (s *Store) StoreSyncStatus() (*StoreSyncStatus, error)
type StoreSyncStatus ¶
type StoreSyncStatus struct { // RemovedServices list of services that can be removed RemovedServices []string `json:"removed_services,omitempty"` // RemovedBackends list of backends that can be removed RemovedBackends []string `json:"removed_backends,omitempty"` // UpdatedServices list of services that can be updated UpdatedServices []string `json:"updated_services,omitempty"` // UpdatedBackends list of backends that can be updated UpdatedBackends []string `json:"updated_backends,omitempty"` // NewServices list of services that can be added NewServices []string `json:"new_services,omitempty"` // NewBackends list of backends that can be added NewBackends []string `json:"new_backends,omitempty"` // Status show final info about sync. May be 'need sync', 'ok' Status string `json:"status"` }
StoreSyncStatus info about synchronization with ext-store
func (*StoreSyncStatus) CheckStatus ¶
func (sync *StoreSyncStatus) CheckStatus() string