sync_strats

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouterSyncStrategyInstant env.RouterSyncStrategyType = "instant"
	ZdbIndexKey               string                     = "index"
	ZdbKey                    string                     = "zdb"
)

Variables

This section is empty.

Functions

func ValidateType

func ValidateType[T boltz.ExtEntity, V any](tx *bbolt.Tx, store db.Store[T], m cmap.ConcurrentMap[string, V], checkF func(T, V) []error) []error

Types

type IndexProvider

type IndexProvider interface {
	// NextIndex provides an index for the supplied MutateContext.
	NextIndex(ctx boltz.MutateContext) (uint64, error)

	// CurrentIndex provides the current index
	CurrentIndex() uint64

	ContextIndex(ctx boltz.MutateContext) *uint64
}

type InstantStrategy

type InstantStrategy struct {
	InstantStrategyOptions

	*common.RouterDataModelSender
	// contains filtered or unexported fields
}

InstantStrategy assumes that on connect, the router requires and instant and full set of API Sessions. Send individual create, update, delete events for sessions after synchronization.

This strategy uses a series of queues and workers to managed synchronization state. The order of events is as follows:

  1. An edge router connects to the controller, triggering RouterConnected()
  2. A RouterSender is created encapsulating the Edge Router, Router, and Sync State
  3. The RouterSender is queued on the routerConnectedQueue channel which buffers up to options.MaxQueuedRouterConnects
  4. The routerConnectedQueue is read and the edge server hello is sent
  5. The controller waits for a client hello to be received via ReceiveClientHello message
  6. The client hello is used to identity the RouterSender associated with the client and is queued on the receivedClientHelloQueue channel which buffers up to options.MaxQueuedClientHellos
  7. A startSynchronizeWorker will pick up the RouterSender from the receivedClientHelloQueue and being to send data to the edge router via the RouterSender

func NewInstantStrategy

func NewInstantStrategy(ae *env.AppEnv, options InstantStrategyOptions) *InstantStrategy

func (*InstantStrategy) AddPublicKey

func (strategy *InstantStrategy) AddPublicKey(cert *tls.Certificate)

func (*InstantStrategy) ApiSessionAdded

func (strategy *InstantStrategy) ApiSessionAdded(apiSession *db.ApiSession)

func (*InstantStrategy) ApiSessionDeleted

func (strategy *InstantStrategy) ApiSessionDeleted(apiSession *db.ApiSession)

func (*InstantStrategy) ApiSessionUpdated

func (strategy *InstantStrategy) ApiSessionUpdated(apiSession *db.ApiSession, _ *db.ApiSessionCertificate)

func (*InstantStrategy) BuildAll

func (strategy *InstantStrategy) BuildAll(rdm *common.RouterDataModelSender) error

func (*InstantStrategy) BuildConfigTypes

func (strategy *InstantStrategy) BuildConfigTypes(index uint64, tx *bbolt.Tx, rdm *common.RouterDataModelSender) error

func (*InstantStrategy) BuildConfigs

func (strategy *InstantStrategy) BuildConfigs(index uint64, tx *bbolt.Tx, rdm *common.RouterDataModelSender) error

func (*InstantStrategy) BuildIdentities

func (strategy *InstantStrategy) BuildIdentities(index uint64, tx *bbolt.Tx, rdm *common.RouterDataModelSender) error

func (*InstantStrategy) BuildPostureChecks

func (strategy *InstantStrategy) BuildPostureChecks(index uint64, tx *bbolt.Tx, rdm *common.RouterDataModelSender) error

func (*InstantStrategy) BuildPublicKeys

func (strategy *InstantStrategy) BuildPublicKeys(tx *bbolt.Tx, rdm *common.RouterDataModelSender) error

func (*InstantStrategy) BuildServicePolicies

func (strategy *InstantStrategy) BuildServicePolicies(tx *bbolt.Tx, rdm *common.RouterDataModelSender) error

func (*InstantStrategy) BuildServices

func (strategy *InstantStrategy) BuildServices(index uint64, tx *bbolt.Tx, rdm *common.RouterDataModelSender) error

func (*InstantStrategy) CaCreate

func (strategy *InstantStrategy) CaCreate(index uint64, ca *db.Ca)

func (*InstantStrategy) CaDelete

func (strategy *InstantStrategy) CaDelete(index uint64, ca *db.Ca)

func (*InstantStrategy) CaUpdate

func (strategy *InstantStrategy) CaUpdate(index uint64, ca *db.Ca)

func (*InstantStrategy) ConfigCreate

func (strategy *InstantStrategy) ConfigCreate(index uint64, entity *db.Config)

func (*InstantStrategy) ConfigDelete

func (strategy *InstantStrategy) ConfigDelete(index uint64, entity *db.Config)

func (*InstantStrategy) ConfigTypeCreate

func (strategy *InstantStrategy) ConfigTypeCreate(index uint64, entity *db.ConfigType)

func (*InstantStrategy) ConfigTypeDelete

func (strategy *InstantStrategy) ConfigTypeDelete(index uint64, entity *db.ConfigType)

func (*InstantStrategy) ConfigTypeUpdate

func (strategy *InstantStrategy) ConfigTypeUpdate(index uint64, entity *db.ConfigType)

func (*InstantStrategy) ConfigUpdate

func (strategy *InstantStrategy) ConfigUpdate(index uint64, entity *db.Config)

func (*InstantStrategy) ContextIndex

func (strategy *InstantStrategy) ContextIndex(ctx boltz.MutateContext) *uint64

func (*InstantStrategy) ControllerCreate

func (strategy *InstantStrategy) ControllerCreate(index uint64, controller *db.Controller)

func (*InstantStrategy) ControllerUpdate

func (strategy *InstantStrategy) ControllerUpdate(index uint64, controller *db.Controller)

func (*InstantStrategy) GetEdgeRouterState

func (strategy *InstantStrategy) GetEdgeRouterState(id string) env.RouterStateValues

func (*InstantStrategy) GetReceiveHandlers

func (strategy *InstantStrategy) GetReceiveHandlers() []channel.TypedReceiveHandler

func (*InstantStrategy) GetRouterDataModel

func (strategy *InstantStrategy) GetRouterDataModel() *common.RouterDataModelSender

func (*InstantStrategy) HandleServicePolicyChange

func (strategy *InstantStrategy) HandleServicePolicyChange(ctx boltz.MutateContext, policyChange *edge_ctrl_pb.DataState_ServicePolicyChange)

func (*InstantStrategy) IdentityCreate

func (strategy *InstantStrategy) IdentityCreate(index uint64, identity *db.Identity)

func (*InstantStrategy) IdentityDelete

func (strategy *InstantStrategy) IdentityDelete(index uint64, identity *db.Identity)

func (*InstantStrategy) IdentityUpdate

func (strategy *InstantStrategy) IdentityUpdate(index uint64, identity *db.Identity)

func (*InstantStrategy) Initialize

func (strategy *InstantStrategy) Initialize(logSize uint64, bufferSize uint) error

Initialize implements RouterDataModelCache

func (*InstantStrategy) NextIndex

func (strategy *InstantStrategy) NextIndex(ctx boltz.MutateContext) (uint64, error)

NextIndex provides an index for the supplied MutateContext.

func (*InstantStrategy) PostureCheckCreate

func (strategy *InstantStrategy) PostureCheckCreate(index uint64, postureCheck *db.PostureCheck)

func (*InstantStrategy) PostureCheckDelete

func (strategy *InstantStrategy) PostureCheckDelete(index uint64, postureCheck *db.PostureCheck)

func (*InstantStrategy) PostureCheckUpdate

func (strategy *InstantStrategy) PostureCheckUpdate(index uint64, postureCheck *db.PostureCheck)

func (*InstantStrategy) ReceiveClientHello

func (strategy *InstantStrategy) ReceiveClientHello(routerId string, msg *channel.Message, respHello *edge_ctrl_pb.ClientHello)

func (*InstantStrategy) ReceiveResync

func (strategy *InstantStrategy) ReceiveResync(routerId string, _ *edge_ctrl_pb.RequestClientReSync)

func (*InstantStrategy) RevocationCreate

func (strategy *InstantStrategy) RevocationCreate(index uint64, revocation *db.Revocation)

func (*InstantStrategy) RevocationDelete

func (strategy *InstantStrategy) RevocationDelete(index uint64, revocation *db.Revocation)

func (*InstantStrategy) RevocationUpdate

func (strategy *InstantStrategy) RevocationUpdate(index uint64, revocation *db.Revocation)

func (*InstantStrategy) RouterConnected

func (strategy *InstantStrategy) RouterConnected(edgeRouter *model.EdgeRouter, router *model.Router)

func (*InstantStrategy) RouterDisconnected

func (strategy *InstantStrategy) RouterDisconnected(router *model.Router)

func (*InstantStrategy) ServiceCreate

func (strategy *InstantStrategy) ServiceCreate(index uint64, service *db.EdgeService)

func (*InstantStrategy) ServiceDelete

func (strategy *InstantStrategy) ServiceDelete(index uint64, service *db.EdgeService)

func (*InstantStrategy) ServicePolicyCreate

func (strategy *InstantStrategy) ServicePolicyCreate(index uint64, servicePolicy *db.ServicePolicy)

func (*InstantStrategy) ServicePolicyDelete

func (strategy *InstantStrategy) ServicePolicyDelete(index uint64, servicePolicy *db.ServicePolicy)

func (*InstantStrategy) ServicePolicyUpdate

func (strategy *InstantStrategy) ServicePolicyUpdate(index uint64, servicePolicy *db.ServicePolicy)

func (*InstantStrategy) ServiceUpdate

func (strategy *InstantStrategy) ServiceUpdate(index uint64, service *db.EdgeService)

func (*InstantStrategy) SessionDeleted

func (strategy *InstantStrategy) SessionDeleted(session *db.Session)

func (*InstantStrategy) Start

func (strategy *InstantStrategy) Start()

func (*InstantStrategy) Stop

func (strategy *InstantStrategy) Stop()

func (*InstantStrategy) Type

func (strategy *InstantStrategy) Type() env.RouterSyncStrategyType

func (*InstantStrategy) Validate

func (strategy *InstantStrategy) Validate() []error

func (*InstantStrategy) ValidateAll

func (strategy *InstantStrategy) ValidateAll(rdm *common.RouterDataModelSender) []error

func (*InstantStrategy) ValidateConfigTypes

func (strategy *InstantStrategy) ValidateConfigTypes(tx *bbolt.Tx, rdm *common.RouterDataModelSender) []error

func (*InstantStrategy) ValidateConfigs

func (strategy *InstantStrategy) ValidateConfigs(tx *bbolt.Tx, rdm *common.RouterDataModelSender) []error

func (*InstantStrategy) ValidateIdentities

func (strategy *InstantStrategy) ValidateIdentities(tx *bbolt.Tx, rdm *common.RouterDataModelSender) []error

func (*InstantStrategy) ValidatePostureChecks

func (strategy *InstantStrategy) ValidatePostureChecks(tx *bbolt.Tx, rdm *common.RouterDataModelSender) []error

func (*InstantStrategy) ValidateServicePolicies

func (strategy *InstantStrategy) ValidateServicePolicies(tx *bbolt.Tx, rdm *common.RouterDataModelSender) []error

func (*InstantStrategy) ValidateServices

func (strategy *InstantStrategy) ValidateServices(tx *bbolt.Tx, rdm *common.RouterDataModelSender) []error

type InstantStrategyOptions

type InstantStrategyOptions struct {
	MaxQueuedRouterConnects  int32
	MaxQueuedClientHellos    int32
	RouterConnectWorkerCount int32
	SyncWorkerCount          int32
	RouterTxBufferSize       int
	HelloSendTimeout         time.Duration
	SessionChunkSize         int
}

InstantStrategyOptions is the options for the instant strategy. - MaxQueuedRouterConnects - max number of router connected events to buffer - MaxQueuedClientHellos - max number of client hello messages to buffer - RouterConnectWorkerCount - max number of workers used to process router connections - SyncWorkerCount - max number of workers used to send api sessions/session data - RouterTxBufferSize - max number of messages buffered to be send to a router - HelloSendTimeout - the max amount of time per worker to wait to send hellos - SessionChunkSize - the number of sessions to send in each message

type InstantSyncState

type InstantSyncState struct {
	Id       string `json:"id"`       //unique id for the sync attempt
	IsLast   bool   `json:"isLast"`   //
	Sequence int    `json:"sequence"` //increasing id from 0 per id for the
}

type NonHaIndexProvider

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

func (*NonHaIndexProvider) ContextIndex

func (p *NonHaIndexProvider) ContextIndex(ctx boltz.MutateContext) *uint64

func (*NonHaIndexProvider) CurrentIndex

func (p *NonHaIndexProvider) CurrentIndex() uint64

func (*NonHaIndexProvider) NextIndex

func (p *NonHaIndexProvider) NextIndex(ctx boltz.MutateContext) (uint64, error)

type RaftIndexProvider

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

func (*RaftIndexProvider) ContextIndex

func (p *RaftIndexProvider) ContextIndex(ctx boltz.MutateContext) *uint64

func (*RaftIndexProvider) CurrentIndex

func (p *RaftIndexProvider) CurrentIndex() uint64

func (*RaftIndexProvider) NextIndex

func (p *RaftIndexProvider) NextIndex(ctx boltz.MutateContext) (uint64, error)

type RouterSender

type RouterSender struct {
	env.RouterState
	Id         string
	EdgeRouter *model.EdgeRouter
	Router     *model.Router

	SupportsRouterModel bool

	sync.Mutex
	// contains filtered or unexported fields
}

RouterSender represents a connection from an Edge Router to the controller. Used to asynchronously buffer and send messages to an Edge Router via Start() then Send()

func (*RouterSender) GetState

func (rtx *RouterSender) GetState() env.RouterStateValues

func (*RouterSender) Send

func (rtx *RouterSender) Send(msg *channel.Message) error

func (*RouterSender) Stop

func (rtx *RouterSender) Stop()

Jump to

Keyboard shortcuts

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