state

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 28 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

func NewApiSessionAddedHandler added in v1.1.1

func NewApiSessionAddedHandler(sm Manager, binding channel.Binding) *apiSessionAddedHandler

func NewApiSessionRemovedHandler added in v1.1.1

func NewApiSessionRemovedHandler(sm Manager) *apiSessionRemovedHandler

func NewApiSessionUpdatedHandler added in v1.1.1

func NewApiSessionUpdatedHandler(sm Manager) *apiSessionUpdatedHandler

func NewDataStateEventHandler added in v1.1.1

func NewDataStateEventHandler(state Manager) channel.TypedReceiveHandler

func NewSessionRemovedHandler added in v1.1.1

func NewSessionRemovedHandler(sm Manager) *sessionRemovedHandler

Types

type ApiSession

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

func NewApiSessionFromToken added in v1.1.1

func NewApiSessionFromToken(jwtToken *jwt.Token, accessClaims *common.AccessClaims) *ApiSession

type DataStateHandler added in v1.1.1

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

func NewDataStateHandler added in v1.1.1

func NewDataStateHandler(state Manager) *DataStateHandler

func (*DataStateHandler) ContentType added in v1.1.1

func (*DataStateHandler) ContentType() int32

func (*DataStateHandler) HandleReceive added in v1.1.1

func (dsh *DataStateHandler) HandleReceive(msg *channel.Message, ch channel.Channel)

type DisconnectCB

type DisconnectCB func(token string)

type Env added in v1.1.1

type Env interface {
	IsHaEnabled() bool
	GetCloseNotify() <-chan struct{}
}

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
	ParseJwt(jwtStr string) (*jwt.Token, *common.AccessClaims, error)

	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(path string, duration time.Duration)
	LoadRouterModel(filePath string)

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

	GetEnv() Env
	UpdateChApiSession(channel.Channel, *ApiSession) error

	env.Xrctrl
}

func NewManager

func NewManager(env Env) 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) BindChannel added in v1.1.1

func (sm *ManagerImpl) BindChannel(binding channel.Binding) error

func (*ManagerImpl) DumpApiSessions

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

func (*ManagerImpl) Enabled added in v1.1.1

func (sm *ManagerImpl) Enabled() bool

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) GetEnv added in v1.1.1

func (sm *ManagerImpl) GetEnv() Env

func (*ManagerImpl) GetTraceDecoders added in v1.1.1

func (sm *ManagerImpl) GetTraceDecoders() []channel.TraceMessageDecoder

func (*ManagerImpl) IsSyncInProgress

func (sm *ManagerImpl) IsSyncInProgress() bool

func (*ManagerImpl) LoadConfig added in v1.1.1

func (sm *ManagerImpl) LoadConfig(cfgmap map[interface{}]interface{}) error

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) NotifyOfReconnect added in v1.1.1

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

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) Run added in v1.1.1

func (sm *ManagerImpl) Run(env.RouterEnv) error

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(filePath string, duration time.Duration)

func (*ManagerImpl) UpdateApiSession

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

func (*ManagerImpl) UpdateChApiSession added in v1.1.1

func (sm *ManagerImpl) UpdateChApiSession(ch channel.Channel, newApiSession *ApiSession) error

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