sync_strats

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 33 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 added in v1.1.8

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 added in v0.34.0

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.RouterDataModel
	// 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 added in v0.34.0

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 added in v0.34.0

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

func (*InstantStrategy) BuildConfigTypes added in v1.1.8

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

func (*InstantStrategy) BuildConfigs added in v1.1.8

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

func (*InstantStrategy) BuildIdentities added in v0.34.0

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

func (*InstantStrategy) BuildPostureChecks added in v0.34.0

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

func (*InstantStrategy) BuildPublicKeys added in v0.34.0

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

func (*InstantStrategy) BuildServicePolicies added in v0.34.0

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

func (*InstantStrategy) BuildServices added in v0.34.0

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

func (*InstantStrategy) CaCreate added in v0.34.0

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

func (*InstantStrategy) CaDelete added in v0.34.0

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

func (*InstantStrategy) CaUpdate added in v0.34.0

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

func (*InstantStrategy) ConfigCreate added in v1.1.8

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

func (*InstantStrategy) ConfigDelete added in v1.1.8

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

func (*InstantStrategy) ConfigTypeCreate added in v1.1.8

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

func (*InstantStrategy) ConfigTypeDelete added in v1.1.8

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

func (*InstantStrategy) ConfigTypeUpdate added in v1.1.8

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

func (*InstantStrategy) ConfigUpdate added in v1.1.8

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

func (*InstantStrategy) ControllerCreate added in v0.34.2

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

func (*InstantStrategy) ControllerUpdate added in v0.34.2

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) IdentityCreate added in v0.34.0

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

func (*InstantStrategy) IdentityDelete added in v0.34.0

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

func (*InstantStrategy) IdentityUpdate added in v0.34.0

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

func (*InstantStrategy) Initialize added in v0.34.0

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

Initialize implements RouterDataModelCache

func (*InstantStrategy) PostureCheckCreate added in v0.34.0

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

func (*InstantStrategy) PostureCheckDelete added in v0.34.0

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

func (*InstantStrategy) PostureCheckUpdate added in v0.34.0

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 added in v0.34.0

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

func (*InstantStrategy) RevocationDelete added in v0.34.0

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

func (*InstantStrategy) RevocationUpdate added in v0.34.0

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 added in v0.34.0

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

func (*InstantStrategy) ServiceDelete added in v0.34.0

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

func (*InstantStrategy) ServicePolicyCreate added in v0.34.0

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

func (*InstantStrategy) ServicePolicyDelete added in v0.34.0

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

func (*InstantStrategy) ServicePolicyUpdate added in v0.34.0

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

func (*InstantStrategy) ServiceUpdate added in v0.34.0

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

func (*InstantStrategy) SessionDeleted

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

func (*InstantStrategy) Stop

func (strategy *InstantStrategy) Stop()

func (*InstantStrategy) Type

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

func (*InstantStrategy) Validate added in v1.1.8

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

func (*InstantStrategy) ValidateAll added in v1.1.8

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

func (*InstantStrategy) ValidateConfigTypes added in v1.1.8

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

func (*InstantStrategy) ValidateConfigs added in v1.1.8

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

func (*InstantStrategy) ValidateIdentities added in v1.1.8

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

func (*InstantStrategy) ValidatePostureChecks added in v1.1.8

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

func (*InstantStrategy) ValidateServicePolicies added in v1.1.8

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

func (*InstantStrategy) ValidateServices added in v1.1.8

func (strategy *InstantStrategy) ValidateServices(tx *bbolt.Tx, rdm *common.RouterDataModel) []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 added in v0.34.0

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

func (*NonHaIndexProvider) ContextIndex added in v1.1.1

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

func (*NonHaIndexProvider) CurrentIndex added in v0.34.0

func (p *NonHaIndexProvider) CurrentIndex() uint64

func (*NonHaIndexProvider) NextIndex added in v0.34.0

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

type RaftIndexProvider added in v0.34.0

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

func (*RaftIndexProvider) ContextIndex added in v1.1.1

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

func (*RaftIndexProvider) CurrentIndex added in v0.34.0

func (p *RaftIndexProvider) CurrentIndex() uint64

func (*RaftIndexProvider) NextIndex added in v0.34.0

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
	RouterModelIndex    *uint64

	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