Documentation
¶
Index ¶
- Constants
- Variables
- type IsServiceHealthCheckedFunc
- type SelectBackendsFunc
- type WriteTxn
- type Writer
- func (w *Writer) Backends() statedb.Table[*loadbalancer.Backend]
- func (w *Writer) BackendsForService(txn statedb.ReadTxn, svc loadbalancer.ServiceName) (iter.Seq2[loadbalancer.BackendParams, statedb.Revision], <-chan struct{})
- func (w *Writer) DebugDump(txn statedb.ReadTxn, to io.Writer)
- func (w *Writer) DefaultSelectBackends(bes iter.Seq2[loadbalancer.BackendParams, statedb.Revision], ...) iter.Seq2[loadbalancer.BackendParams, statedb.Revision]
- func (w *Writer) DeleteBackendsBySource(txn WriteTxn, source source.Source) error
- func (w *Writer) DeleteBackendsOfService(txn WriteTxn, name loadbalancer.ServiceName, src source.Source) error
- func (w *Writer) DeleteBackendsOfServiceFromCluster(txn WriteTxn, name loadbalancer.ServiceName, src source.Source, ...) error
- func (w *Writer) DeleteFrontend(txn WriteTxn, addr loadbalancer.L3n4Addr)
- func (w *Writer) DeleteServiceAndFrontends(txn WriteTxn, name loadbalancer.ServiceName) (*loadbalancer.Service, error)
- func (w *Writer) DeleteServicesBySource(txn WriteTxn, source source.Source) error
- func (w *Writer) Frontends() statedb.Table[*loadbalancer.Frontend]
- func (w *Writer) IsEnabled() bool
- func (w *Writer) ReadTxn() statedb.ReadTxn
- func (w *Writer) RefreshFrontends(txn WriteTxn, name loadbalancer.ServiceName) error
- func (w *Writer) RegisterInitializer(name string) (complete func(WriteTxn))
- func (w *Writer) ReleaseBackends(txn WriteTxn, name loadbalancer.ServiceName, ...) error
- func (w *Writer) SelectBackends(bes iter.Seq2[loadbalancer.BackendParams, statedb.Revision], ...) iter.Seq2[loadbalancer.BackendParams, statedb.Revision]
- func (w *Writer) SelectBackendsForHealthChecking(bes iter.Seq2[loadbalancer.BackendParams, statedb.Revision], ...) iter.Seq2[loadbalancer.BackendParams, statedb.Revision]
- func (w *Writer) Services() statedb.Table[*loadbalancer.Service]
- func (w *Writer) SetBackends(txn WriteTxn, name loadbalancer.ServiceName, source source.Source, ...) error
- func (w *Writer) SetBackendsOfCluster(txn WriteTxn, name loadbalancer.ServiceName, source source.Source, ...) error
- func (w *Writer) SetIsServiceHealthCheckedFunc(fn IsServiceHealthCheckedFunc)
- func (w *Writer) SetRedirectTo(txn WriteTxn, fe *loadbalancer.Frontend, to *loadbalancer.ServiceName)
- func (w *Writer) SetSelectBackendsFunc(fn SelectBackendsFunc)
- func (w *Writer) UpdateBackendHealth(txn WriteTxn, serviceName loadbalancer.ServiceName, ...) (bool, error)
- func (w *Writer) UpsertAndReleaseBackends(txn WriteTxn, serviceName loadbalancer.ServiceName, source source.Source, ...) error
- func (w *Writer) UpsertBackends(txn WriteTxn, serviceName loadbalancer.ServiceName, source source.Source, ...) error
- func (w *Writer) UpsertFrontend(txn WriteTxn, params loadbalancer.FrontendParams) (old *loadbalancer.Frontend, err error)
- func (w *Writer) UpsertService(txn WriteTxn, svc *loadbalancer.Service) (old *loadbalancer.Service, err error)
- func (w *Writer) UpsertServiceAndFrontends(txn WriteTxn, svc *loadbalancer.Service, fes ...loadbalancer.FrontendParams) error
- func (w *Writer) WriteTxn(extraTables ...statedb.TableMeta) WriteTxn
Constants ¶
const LocalClusterID = 0
Backends for the local cluster are associated with ID 0, regardless of the real cluster id.
Variables ¶
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 SelectBackendsFunc ¶
type SelectBackendsFunc = func(iter.Seq2[loadbalancer.BackendParams, statedb.Revision], *loadbalancer.Service, *loadbalancer.Frontend) iter.Seq2[loadbalancer.BackendParams, statedb.Revision]
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer provides validated write access to the service load-balancing state.
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) DefaultSelectBackends ¶
func (w *Writer) DefaultSelectBackends(bes iter.Seq2[loadbalancer.BackendParams, statedb.Revision], svc *loadbalancer.Service, fe *loadbalancer.Frontend) iter.Seq2[loadbalancer.BackendParams, statedb.Revision]
func (*Writer) DeleteBackendsBySource ¶
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 ¶
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) 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 ¶
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 ¶
func (w *Writer) SelectBackends(bes iter.Seq2[loadbalancer.BackendParams, statedb.Revision], svc *loadbalancer.Service, optionalFrontend *loadbalancer.Frontend) iter.Seq2[loadbalancer.BackendParams, statedb.Revision]
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
func (w *Writer) SelectBackendsForHealthChecking(bes iter.Seq2[loadbalancer.BackendParams, statedb.Revision], svc *loadbalancer.Service, optionalFrontend *loadbalancer.Frontend) iter.Seq2[loadbalancer.BackendParams, statedb.Revision]
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.