gateway

package
v0.4.31 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: GPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultProtocol         = "tcp"
	DefaultSchedulingMethod = "wrr"
)
View Source
const (
	PlatformSupportIPVS = true
)

Variables

View Source
var (
	ErrMissingEndpoint = errors.New("endpoint information is missing")
	ErrUnknownProtocol = errors.New("specified protocol is unknown")
)

Possible validation errors.

View Source
var (
	ErrIPVSFailed      = errors.New("error while calling into IPVS")
	ErrBackendExists   = errors.New("backend already exists")
	ErrServiceNotFound = errors.New("virtual service not found")
	ErrBackendNotFound = errors.New("backend not found")
)

Functions

func GetOutboundIP

func GetOutboundIP() (net.IP, error)

Types

type Gateway

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

func NewGateway

func NewGateway(ctx context.Context) (*Gateway, error)

func (*Gateway) Close

func (g *Gateway) Close()

func (*Gateway) CreateBackend

func (g *Gateway) CreateBackend(vsID, rsID string, options *RealOptions) error

CreateBackend registers a new backend with the virtual service.

func (*Gateway) CreateService

func (g *Gateway) CreateService(vsID string, options *ServiceOptions) error

CreateService registers a new virtual service with IPVS.

func (*Gateway) GetMetrics

func (g *Gateway) GetMetrics(vsID string) (*Metrics, error)

Metrics returns some metrics for a given virtual service.

func (*Gateway) RemoveBackend

func (g *Gateway) RemoveBackend(vsID, rsID string) (*RealOptions, error)

RemoveBackend deregisters a backend from the virtual service.

func (*Gateway) RemoveService

func (g *Gateway) RemoveService(vsID string) (*ServiceOptions, error)

RemoveService deregisters a virtual service.

type Metrics

type Metrics struct {
	Connections uint64
	InPackets   uint64
	OutPackets  uint64
	InBytes     uint64
	OutBytes    uint64

	ConnectionsPerSecond uint64
	InPacketsPerSecond   uint64
	OutPacketsPerSecond  uint64
	InBytesPerSecond     uint64
	OutBytesPerSecond    uint64
}

Metrics describes a virtual service metrics.

func (*Metrics) Add

func (m *Metrics) Add(metrics *Metrics)

type PortPool

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

func NewPortPool

func NewPortPool(init, size uint16) *PortPool

func (*PortPool) Assign

func (p *PortPool) Assign(ID string) (uint16, error)

func (*PortPool) Retain

func (p *PortPool) Retain(ID string) error

type RealOptions

type RealOptions struct {
	Host   string
	Port   uint16
	Weight int32
	VsID   string
	// contains filtered or unexported fields
}

RealOptions describe a virtual service real.

func NewRealOptions

func NewRealOptions(host string, port uint16, weight int32, vsID string) (*RealOptions, error)

NewRealOptions constructs new real service options.

type Route added in v0.4.1

type Route struct {
	ID          string
	Protocol    string
	Host        string
	Port        uint16
	BackendHost string
	BackendPort uint16
}

type Router added in v0.4.1

type Router interface {
	// Register registers a new virtual service specified by the given ID.
	Register(ID string, protocol string) (VirtualService, error)
	// Deregister deregisters a virtual service specified by the given ID.
	Deregister(ID string) error
	// GetMetrics returns gateway-specific metrics.
	GetMetrics() (*Metrics, error)
	// Close closes the router, freeing all associated resources.
	Close() error
}

type ServiceOptions

type ServiceOptions struct {
	Host       string
	Port       uint16
	Protocol   string
	Method     string
	Persistent bool
	// contains filtered or unexported fields
}

ServiceOptions describe a virtual service.

func NewServiceOptions

func NewServiceOptions(host string, port uint16, protocol string) (*ServiceOptions, error)

NewServiceOptions constructs new virtual service options.

type VirtualService added in v0.4.1

type VirtualService interface {
	// ID returns this virtual service's ID.
	ID() string
	// AddReal registers a new real service endpoint under the current virtual
	// service.
	// Host parameter may be both FQDN and IP address.
	AddReal(ID string, host string, port uint16) (*Route, error)
	// RemoveReal removes the real service specified by the ID from the
	// current virtual service.
	// Established connections won't be affected.
	RemoveReal(ID string) error
}

VirtualService describes a virtual service.

Jump to

Keyboard shortcuts

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