writer

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const LocalClusterID = 0

Backends for the local cluster are associated with ID 0, regardless of the real cluster id.

Variables

View Source
var Cell = cell.Module(
	"loadbalancer-writer",
	"Tables and Writer API for manipulating load-balancing state",

	cell.ProvidePrivate(
		loadbalancer.NewServicesTable,
		loadbalancer.NewFrontendsTable,
		loadbalancer.NewBackendsTable,
	),

	cell.Provide(

		NewWriter,

		statedb.RWTable[*loadbalancer.Service].ToTable,
		statedb.RWTable[*loadbalancer.Frontend].ToTable,
		statedb.RWTable[*loadbalancer.Backend].ToTable,
	),

	cell.Invoke(registerNodeZoneWatcher),

	cell.Invoke(registerNodePortAddressReconciler),
)

Cell provides the Writer API for configuring load-balancing and the Table[*Service], Table[*Frontend] and Table[*Backend] for read-only access to load-balancing state.

Functions

This section is empty.

Types

type IsServiceHealthCheckedFunc added in v1.18.2

type IsServiceHealthCheckedFunc = func(*loadbalancer.Service) bool

type WriteTxn

type WriteTxn struct {
	statedb.WriteTxn
}

type Writer

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

Writer provides validated write access to the service load-balancing state.

func NewWriter

func NewWriter(p writerParams) (*Writer, error)

func (*Writer) Backends

func (w *Writer) Backends() statedb.Table[*loadbalancer.Backend]

Backends returns the backend table for reading. Convenience method for reducing dependencies.

func (*Writer) BackendsForService

func (w *Writer) BackendsForService(txn statedb.ReadTxn, svc loadbalancer.ServiceName) (iter.Seq2[loadbalancer.BackendParams, statedb.Revision], <-chan struct{})

BackendsForService returns all backends associated with a given service without any filtering.

func (*Writer) DebugDump

func (w *Writer) DebugDump(txn statedb.ReadTxn, to io.Writer)

func (*Writer) DeleteBackendsBySource

func (w *Writer) DeleteBackendsBySource(txn WriteTxn, source source.Source) error

DeletesBackendsBySource deletes all backends from the specific source.

func (*Writer) DeleteBackendsOfService

func (w *Writer) DeleteBackendsOfService(txn WriteTxn, name loadbalancer.ServiceName, src source.Source) error

func (*Writer) DeleteBackendsOfServiceFromCluster

func (w *Writer) DeleteBackendsOfServiceFromCluster(txn WriteTxn, name loadbalancer.ServiceName, src source.Source, clusterID uint32) error

func (*Writer) DeleteFrontend added in v1.18.2

func (w *Writer) DeleteFrontend(txn WriteTxn, addr loadbalancer.L3n4Addr)

func (*Writer) DeleteServiceAndFrontends

func (w *Writer) DeleteServiceAndFrontends(txn WriteTxn, name loadbalancer.ServiceName) (*loadbalancer.Service, error)

func (*Writer) DeleteServicesBySource

func (w *Writer) DeleteServicesBySource(txn WriteTxn, source source.Source) error

DeleteServicesBySource deletes all services from the specific source. This is used to implement "resynchronization", for example with K8s when the Watch() call fails and we need to start over with a List().

func (*Writer) Frontends

func (w *Writer) Frontends() statedb.Table[*loadbalancer.Frontend]

Frontends returns the frontend table for reading. Convenience method for reducing dependencies.

func (*Writer) IsEnabled

func (w *Writer) IsEnabled() bool

func (*Writer) ReadTxn

func (w *Writer) ReadTxn() statedb.ReadTxn

ReadTxn returns a StateDB read transaction. Convenience method to be used with the above table getters.

func (*Writer) RefreshFrontends

func (w *Writer) RefreshFrontends(txn WriteTxn, name loadbalancer.ServiceName) error

func (*Writer) RegisterInitializer

func (w *Writer) RegisterInitializer(name string) (complete func(WriteTxn))

RegisterInitializer registers a component as an initializer to the load-balancing tables. This blocks pruning of data until this and all other registered initializers have called the returned 'complete' function.

func (*Writer) ReleaseBackends

func (w *Writer) ReleaseBackends(txn WriteTxn, name loadbalancer.ServiceName, addrs iter.Seq[loadbalancer.L3n4Addr]) error

func (*Writer) SelectBackends

SelectBackends filters backends associated with [svc]. If [optionalFrontend] is non-nil, then backends are further filtered by frontend IP family, protocol and port name.

func (*Writer) SelectBackendsForHealthChecking added in v1.18.2

SelectBackendsForHealthChecking filters backends associated with [svc]. If [optionalFrontend] is non-nil, then backends are further filtered by frontend IP family, protocol and port name.

func (*Writer) Services

func (w *Writer) Services() statedb.Table[*loadbalancer.Service]

Services returns the service table for reading. Convenience method for reducing dependencies.

func (*Writer) SetBackends

func (w *Writer) SetBackends(txn WriteTxn, name loadbalancer.ServiceName, source source.Source, bes ...loadbalancer.BackendParams) error

SetBackends sets the backends associated with a service. Existing backends from this source that are associated with the service but are not given are released.

func (*Writer) SetBackendsOfCluster

func (w *Writer) SetBackendsOfCluster(txn WriteTxn, name loadbalancer.ServiceName, source source.Source, clusterID uint32, bes ...loadbalancer.BackendParams) error

SetBackendsOfCluster sets the backends associated with a service from the specified cluster. It will not affect the backends from other clusters associated with the service.

func (*Writer) SetIsServiceHealthCheckedFunc added in v1.18.2

func (w *Writer) SetIsServiceHealthCheckedFunc(fn IsServiceHealthCheckedFunc)

func (*Writer) SetRedirectTo

func (w *Writer) SetRedirectTo(txn WriteTxn, fe *loadbalancer.Frontend, to *loadbalancer.ServiceName)

func (*Writer) SetSelectBackendsFunc

func (w *Writer) SetSelectBackendsFunc(fn SelectBackendsFunc)

func (*Writer) UpdateBackendHealth

func (w *Writer) UpdateBackendHealth(txn WriteTxn, serviceName loadbalancer.ServiceName, backend loadbalancer.L3n4Addr, healthy bool) (bool, error)

func (*Writer) UpsertAndReleaseBackends

func (w *Writer) UpsertAndReleaseBackends(txn WriteTxn, serviceName loadbalancer.ServiceName, source source.Source, new iter.Seq[loadbalancer.BackendParams], orphans iter.Seq[loadbalancer.L3n4Addr]) error

func (*Writer) UpsertBackends

func (w *Writer) UpsertBackends(txn WriteTxn, serviceName loadbalancer.ServiceName, source source.Source, bes iter.Seq[loadbalancer.BackendParams]) error

UpsertBackends adds/updates backends for the given service.

func (*Writer) UpsertFrontend

func (w *Writer) UpsertFrontend(txn WriteTxn, params loadbalancer.FrontendParams) (old *loadbalancer.Frontend, err error)

func (*Writer) UpsertService

func (w *Writer) UpsertService(txn WriteTxn, svc *loadbalancer.Service) (old *loadbalancer.Service, err error)

func (*Writer) UpsertServiceAndFrontends

func (w *Writer) UpsertServiceAndFrontends(txn WriteTxn, svc *loadbalancer.Service, fes ...loadbalancer.FrontendParams) error

UpsertServiceAndFrontends upserts the service and updates the set of associated frontends. Any frontends that do not exist in the new set are deleted.

func (*Writer) WriteTxn

func (w *Writer) WriteTxn(extraTables ...statedb.TableMeta) WriteTxn

WriteTxn returns a write transaction against services & backends and other additional tables to be used with the methods of Writer. The returned transaction MUST be Abort()'ed or Commit()'ed.

Jump to

Keyboard shortcuts

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