sync_strats

package
v0.20.106 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouterSyncStrategyInstant env.RouterSyncStrategyType = "instant"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InstantStrategy

type InstantStrategy struct {
	InstantStrategyOptions
	// 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) ApiSessionAdded

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

func (*InstantStrategy) ApiSessionDeleted

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

func (*InstantStrategy) ApiSessionUpdated

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

func (*InstantStrategy) GetEdgeRouterState added in v0.19.20

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

func (*InstantStrategy) ReceiveClientHello

func (strategy *InstantStrategy) ReceiveClientHello(r *network.Router, respHello *edge_ctrl_pb.ClientHello)

func (*InstantStrategy) ReceiveResync

func (strategy *InstantStrategy) ReceiveResync(r *network.Router, _ *edge_ctrl_pb.RequestClientReSync)

func (*InstantStrategy) RouterConnected

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

func (*InstantStrategy) RouterDisconnected

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

func (*InstantStrategy) SessionDeleted

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

func (*InstantStrategy) Stop

func (strategy *InstantStrategy) Stop()

func (*InstantStrategy) Type

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

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 RouterSender

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

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

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

func (*RouterSender) Send

func (rtx *RouterSender) Send(msg *channel2.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