state

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventRemovedEdgeSession = "RemovedEdgeSession"

	EventAddedApiSession   = "AddedApiSession"
	EventUpdatedApiSession = "UpdatedApiSession"
	EventRemovedApiSession = "RemovedApiSession"

	RouterDataModelListerBufferSize = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiSession

type ApiSession struct {
	*edge_ctrl_pb.ApiSession
	JwtToken *jwt.Token
	Claims   *common.AccessClaims
}

type DisconnectCB

type DisconnectCB func(token string)

type Manager

type Manager interface {
	//"Network" Sessions
	RemoveEdgeSession(token string)
	AddEdgeSessionRemovedListener(token string, callBack func(token string)) RemoveListener
	WasSessionRecentlyRemoved(token string) bool
	MarkSessionRecentlyRemoved(token string)

	//ApiSessions
	GetApiSession(token string) *ApiSession
	GetApiSessionWithTimeout(token string, timeout time.Duration) *ApiSession
	AddApiSession(apiSession *edge_ctrl_pb.ApiSession)
	UpdateApiSession(apiSession *edge_ctrl_pb.ApiSession)
	RemoveApiSession(token string)
	RemoveMissingApiSessions(knownSessions []*edge_ctrl_pb.ApiSession, beforeSessionId string)
	AddConnectedApiSession(token string)
	RemoveConnectedApiSession(token string)
	AddConnectedApiSessionWithChannel(token string, removeCB func(), ch channel.Channel)
	RemoveConnectedApiSessionWithChannel(token string, underlay channel.Channel)
	AddApiSessionRemovedListener(token string, callBack func(token string)) RemoveListener

	RouterDataModel() *common.RouterDataModel
	SetRouterDataModel(model *common.RouterDataModel)

	StartHeartbeat(env env.RouterEnv, seconds int, closeNotify <-chan struct{})
	ValidateSessions(ch channel.Channel, chunkSize uint32, minInterval, maxInterval time.Duration)

	DumpApiSessions(c *bufio.ReadWriter) error
	MarkSyncInProgress(trackerId string)
	MarkSyncStopped(trackerId string)
	IsSyncInProgress() bool

	VerifyClientCert(cert *x509.Certificate) error

	StartRouterModelSave(routerEnv env.RouterEnv, path string, duration time.Duration)
	LoadRouterModel(filePath string)

	AddActiveChannel(ch channel.Channel, session *ApiSession)
	RemoveActiveChannel(ch channel.Channel)
	GetApiSessionFromCh(ch channel.Channel) *ApiSession

	GetConfig() *router.Config
}

func NewManager

func NewManager(config *router.Config) Manager

type ManagerImpl

type ManagerImpl struct {
	Hostname       string
	ControllerAddr string
	ClusterId      string
	NodeId         string
	events.EventEmmiter
	// contains filtered or unexported fields
}

func (*ManagerImpl) ActiveApiSessionTokens

func (sm *ManagerImpl) ActiveApiSessionTokens() []string

func (*ManagerImpl) AddActiveChannel

func (sm *ManagerImpl) AddActiveChannel(ch channel.Channel, session *ApiSession)

func (*ManagerImpl) AddApiSession

func (sm *ManagerImpl) AddApiSession(apiSession *edge_ctrl_pb.ApiSession)

func (*ManagerImpl) AddApiSessionRemovedListener

func (sm *ManagerImpl) AddApiSessionRemovedListener(token string, callBack func(token string)) RemoveListener

func (*ManagerImpl) AddConnectedApiSession

func (sm *ManagerImpl) AddConnectedApiSession(token string)

func (*ManagerImpl) AddConnectedApiSessionWithChannel

func (sm *ManagerImpl) AddConnectedApiSessionWithChannel(token string, removeCB func(), ch channel.Channel)

func (*ManagerImpl) AddEdgeSessionRemovedListener

func (sm *ManagerImpl) AddEdgeSessionRemovedListener(token string, callBack func(token string)) RemoveListener

func (*ManagerImpl) DumpApiSessions

func (sm *ManagerImpl) DumpApiSessions(c *bufio.ReadWriter) error

func (*ManagerImpl) GetApiSession

func (sm *ManagerImpl) GetApiSession(token string) *ApiSession

func (*ManagerImpl) GetApiSessionFromCh

func (sm *ManagerImpl) GetApiSessionFromCh(ch channel.Channel) *ApiSession

func (*ManagerImpl) GetApiSessionWithTimeout

func (sm *ManagerImpl) GetApiSessionWithTimeout(token string, timeout time.Duration) *ApiSession

func (*ManagerImpl) GetConfig

func (sm *ManagerImpl) GetConfig() *router.Config

func (*ManagerImpl) IsSyncInProgress

func (sm *ManagerImpl) IsSyncInProgress() bool

func (*ManagerImpl) LoadRouterModel

func (sm *ManagerImpl) LoadRouterModel(filePath string)

func (*ManagerImpl) MarkSessionRecentlyRemoved

func (sm *ManagerImpl) MarkSessionRecentlyRemoved(token string)

func (*ManagerImpl) MarkSyncInProgress

func (sm *ManagerImpl) MarkSyncInProgress(trackerId string)

func (*ManagerImpl) MarkSyncStopped

func (sm *ManagerImpl) MarkSyncStopped(trackerId string)

func (*ManagerImpl) ParseJwt

func (sm *ManagerImpl) ParseJwt(jwtStr string) (*jwt.Token, *common.AccessClaims, error)

func (*ManagerImpl) RemoveActiveChannel

func (sm *ManagerImpl) RemoveActiveChannel(ch channel.Channel)

func (*ManagerImpl) RemoveApiSession

func (sm *ManagerImpl) RemoveApiSession(token string)

func (*ManagerImpl) RemoveConnectedApiSession

func (sm *ManagerImpl) RemoveConnectedApiSession(token string)

func (*ManagerImpl) RemoveConnectedApiSessionWithChannel

func (sm *ManagerImpl) RemoveConnectedApiSessionWithChannel(token string, ch channel.Channel)

func (*ManagerImpl) RemoveEdgeSession

func (sm *ManagerImpl) RemoveEdgeSession(token string)

func (*ManagerImpl) RemoveMissingApiSessions

func (sm *ManagerImpl) RemoveMissingApiSessions(knownApiSessions []*edge_ctrl_pb.ApiSession, beforeSessionId string)

RemoveMissingApiSessions removes API Sessions not present in the knownApiSessions argument. If the beforeSessionId value is not empty string, it will be used as a monotonic comparison between it and API session ids. API session ids later than the sync will be ignored.

func (*ManagerImpl) RouterDataModel

func (sm *ManagerImpl) RouterDataModel() *common.RouterDataModel

func (*ManagerImpl) SessionConnectionClosed

func (sm *ManagerImpl) SessionConnectionClosed(token string)

func (*ManagerImpl) SetRouterDataModel

func (sm *ManagerImpl) SetRouterDataModel(model *common.RouterDataModel)

func (*ManagerImpl) StartHeartbeat

func (sm *ManagerImpl) StartHeartbeat(env env.RouterEnv, intervalSeconds int, closeNotify <-chan struct{})

func (*ManagerImpl) StartRouterModelSave

func (sm *ManagerImpl) StartRouterModelSave(routerEnv env.RouterEnv, filePath string, duration time.Duration)

func (*ManagerImpl) UpdateApiSession

func (sm *ManagerImpl) UpdateApiSession(apiSession *edge_ctrl_pb.ApiSession)

func (*ManagerImpl) ValidateSessions

func (sm *ManagerImpl) ValidateSessions(ch channel.Channel, chunkSize uint32, minInterval, maxInterval time.Duration)

func (*ManagerImpl) VerifyClientCert

func (sm *ManagerImpl) VerifyClientCert(cert *x509.Certificate) error

func (*ManagerImpl) WasSessionRecentlyRemoved

func (sm *ManagerImpl) WasSessionRecentlyRemoved(token string) bool

type MapWithMutex

type MapWithMutex struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*MapWithMutex) Put

func (self *MapWithMutex) Put(ch channel.Channel, f func())

func (*MapWithMutex) Visit

func (self *MapWithMutex) Visit(cb func(ch channel.Channel, closeCb func()))

type RemoveListener

type RemoveListener func()

type TokenProvider

type TokenProvider interface {
	ActiveApiSessionTokens() []string
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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