l3b

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package l3b implements L3b module.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBackendWithSharedMemory added in v0.2.0

func NewBackendWithSharedMemory(operations SharedMemoryOps) *backend

NewBackendWithSharedMemory serializes writes independently of reads.

func NewSharedMemoryOps added in v0.2.0

func NewSharedMemoryOps(agent *ffi.Agent) agentOps

NewSharedMemoryOps preserves C ownership and publication through the agent.

func RingFromWeights

func RingFromWeights(weights []uint32) []uint32

RingFromWeights expands per-server weights into a weighted-round-robin scheduler ring: each server index appears as many times as its weight, but the occurrences are interleaved so a heavy server is spread evenly across the ring rather than clustered.

Types

type Backend

type Backend interface {
	// CreateService creates a named virtual service.
	CreateService(service *l3bpb.VirtualService) error
	// UpdateService replaces an existing named virtual service.
	UpdateService(service *l3bpb.VirtualService) error
	// DeleteService removes a named virtual service.
	DeleteService(name string) error
	// ListServices returns the names of all virtual services.
	ListServices() []string
	// UpdateModuleConfig installs destination filters and services into a
	// named module configuration and publishes it.
	UpdateModuleConfig(config *l3bpb.ModuleConfig) error
	// ListModuleConfigs returns the names of all module configurations.
	ListModuleConfigs() []string
	// UpdateRealServerState enables or disables a real server within a
	// named virtual service.
	UpdateRealServerState(service string, realServerIndex uint32, enabled bool) error
	// UpdateRealServerWeight sets the weight of a real server within a named
	// virtual service and rebuilds its scheduler ring.
	UpdateRealServerWeight(service string, realServerIndex uint32, weight uint32) error
	// ListSessions pages through the session records of a named virtual
	// service. Returns the page, the continuation token (0 when complete)
	// and the dataplane time the deadlines are relative to.
	ListSessions(
		service string,
		cursor uint64,
		limit uint32,
	) ([]cl3bobject.Session, uint64, uint64, error)
	// GetService returns an owned snapshot of accepted configuration and state.
	//
	// Runtime state and weights become visible after the shared-memory call
	// returns, including applied changes when a ring rebuild fails.
	GetService(service string) (*l3bpb.GetServiceResponse, error)
}

Backend abstracts the shared-memory operations behind the l3b service.

func NewBackend

func NewBackend(agent *ffi.Agent) Backend

NewBackend operates on real shared memory through the supplied agent.

type Config

type Config struct {
	ffi.AttachConfig `yaml:",inline"`

	Endpoint xcfg.NonEmptyString `yaml:"endpoint"`
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) Default

func (m *Config) Default()

Default resets Config to DefaultConfig.

type L3BModule

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

L3BModule is the control-plane component of the l3b module.

func NewL3BModule

func NewL3BModule(cfg *Config, options ...Option) (*L3BModule, error)

func (*L3BModule) Close

func (m *L3BModule) Close() error

Close closes the module.

func (*L3BModule) Endpoint

func (m *L3BModule) Endpoint() string

func (*L3BModule) Name

func (m *L3BModule) Name() string

func (*L3BModule) RegisterService

func (m *L3BModule) RegisterService(server *grpc.Server)

func (*L3BModule) ServicesNames

func (m *L3BModule) ServicesNames() []string

type L3BService

type L3BService struct {
	l3bpb.UnimplementedL3BServiceServer
	// contains filtered or unexported fields
}

L3BService implements the L3BService gRPC server.

func NewL3BService

func NewL3BService(backend Backend) *L3BService

NewL3BService constructs an L3BService backed by the given Backend.

func (*L3BService) CreateService

CreateService creates a named virtual service.

func (*L3BService) DeleteService

DeleteService removes a named virtual service.

func (*L3BService) GetService

GetService inspects a named virtual service: its scheduler masks and the live real servers with addresses, weights and states.

func (*L3BService) ListModuleConfigs

ListModuleConfigs returns the names of all module configurations.

func (*L3BService) ListServices

ListServices returns the names of all virtual services.

func (*L3BService) ListSessions

ListSessions pages through the session records of a named virtual service.

func (*L3BService) UpdateModuleConfig

UpdateModuleConfig installs destination filters and services into a named module configuration.

func (*L3BService) UpdateRealServerState

UpdateRealServerState enables or disables a real server within a named virtual service.

func (*L3BService) UpdateRealServerWeight

UpdateRealServerWeight sets the weight of a real server within a named virtual service.

func (*L3BService) UpdateService

UpdateService replaces an existing named virtual service.

type ModuleHandle added in v0.2.0

type ModuleHandle interface {
	Free() error
	Update([]cl3b.DestinationFilterRule) error
	AsFFIModule() ffi.ModuleConfig
}

ModuleHandle is a module configuration owned by the backend.

type Option

type Option func(*moduleOptions)

Option configures the L3BModule constructor.

func WithLog

func WithLog(log *zap.Logger) Option

WithLog sets the logger for the l3b module.

type SessionTableHandle added in v0.2.0

type SessionTableHandle interface {
	Free() error
}

SessionTableHandle is a session table owned by the backend.

type SharedMemoryOps added in v0.2.0

type SharedMemoryOps interface {
	WorkerCount() uint32
	CreateSessionTable(string, uint16, uint32) (SessionTableHandle, error)
	CreateVirtualService(string, cl3bobject.VirtualServiceConfig, SessionTableHandle) (VirtualServiceHandle, error)
	DeleteVirtualService(string) error
	NewModuleConfig(string) (ModuleHandle, error)
	UpdateModules([]ffi.ModuleConfig) error
}

SharedMemoryOps separates allocation and publication from backend bookkeeping.

type VirtualServiceHandle added in v0.2.0

type VirtualServiceHandle interface {
	Free() error
	Publish() error
	UpdateRing([]uint32) error
	SetRealServerState(uint32, bool) error
	ReadSessions(uint64, uint32) ([]cl3bobject.Session, uint64, uint64, error)
}

VirtualServiceHandle is a service object owned by the backend.

Directories

Path Synopsis
l3bpb
v1

Jump to

Keyboard shortcuts

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