state

package
v2.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionState

type SessionState interface {
	Cancel()
	Done() <-chan struct{}
	LastMarked() time.Time
	SetLastMarked(lastMarked time.Time)
}

type State

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

State is the total state of the Traffic Manager. A zero State is invalid; you must call NewState.

func NewState

func NewState(ctx context.Context) *State

func (*State) AddAgent

func (s *State) AddAgent(agent *rpc.AgentInfo, now time.Time) string

func (*State) AddClient

func (s *State) AddClient(client *rpc.ClientInfo, now time.Time) string

func (*State) AddIntercept

func (s *State) AddIntercept(sessionID, apiKey string, spec *rpc.InterceptSpec) (*rpc.InterceptInfo, error)

func (*State) AgentTunnel added in v2.3.2

func (s *State) AgentTunnel(ctx context.Context, clientSessionInfo *rpc.SessionInfo, tunnel connpool.Tunnel) error

func (*State) AgentsLookup added in v2.3.0

func (s *State) AgentsLookup(ctx context.Context, clientSessionID string, request *rpc.LookupHostRequest) (iputil.IPs, error)

AgentsLookup will send the given request to all agents currently intercepted by the client identified with the clientSessionID, it will then wait for results to arrive, collect those results, and return them as a unique and sorted slice.

func (*State) ClientTunnel added in v2.3.2

func (s *State) ClientTunnel(ctx context.Context, tunnel connpool.Tunnel) error

func (*State) ExpireSessions

func (s *State) ExpireSessions(moment time.Time)

ExpireSessions prunes any sessions that haven't had a MarkSession heartbeat since the given 'moment'.

func (*State) GetAgent

func (s *State) GetAgent(sessionID string) *rpc.AgentInfo

func (*State) GetAgentsByName

func (s *State) GetAgentsByName(name, namespace string) map[string]*rpc.AgentInfo

func (*State) GetAllAgents

func (s *State) GetAllAgents() map[string]*rpc.AgentInfo

func (*State) GetAllClients

func (s *State) GetAllClients() map[string]*rpc.ClientInfo

func (*State) GetClient

func (s *State) GetClient(sessionID string) *rpc.ClientInfo

func (*State) GetIntercept

func (s *State) GetIntercept(interceptID string) *rpc.InterceptInfo

func (*State) GetInterceptAPIKey added in v2.3.1

func (s *State) GetInterceptAPIKey() string

GetInterceptAPIKey returns the first non-empty apiKey associated with an intercept IDs. We use this fuction as a last resort if we need to garbage collect intercepts when there are no active sessions.

func (*State) InitialTempLogLevel added in v2.4.2

func (s *State) InitialTempLogLevel() *rpc.LogLevelRequest

InitialTempLogLevel returns the temporary log-level if it exists, along with the remaining duration for it, which might be zero, in which case the log-level is valid until a new level is requested.

func (*State) MarkSession

func (s *State) MarkSession(req *rpc.RemainRequest, now time.Time) (ok bool)

MarkSession marks a session as being present at the indicated time. Returns true if everything goes OK, returns false if the given session ID does not exist.

func (*State) PostLookupResponse added in v2.3.0

func (s *State) PostLookupResponse(response *rpc.LookupHostAgentResponse)

PostLookupResponse receives lookup responses from an agent and places them in the channel that corresponds to the lookup request

func (*State) RemoveIntercept

func (s *State) RemoveIntercept(interceptID string) bool

func (*State) RemoveInterceptAPIKey added in v2.3.1

func (s *State) RemoveInterceptAPIKey(interceptID string) bool

RemoveInterceptAPIKey removes the associated APIKey for an Intercept ID Only call on an intercept that has been deleted.

func (*State) RemoveSession

func (s *State) RemoveSession(sessionID string)

RemoveSession removes a session from the set of present session IDs.

func (*State) SessionDone

func (s *State) SessionDone(id string) <-chan struct{}

SessionDone returns a channel that is closed when the session with the given ID terminates. If there is no such currently-live session, then an already-closed channel is returned.

func (*State) SetTempLogLevel added in v2.4.2

func (s *State) SetTempLogLevel(ctx context.Context, logLevelRequest *rpc.LogLevelRequest)

SetTempLogLevel sets the temporary log-level for the traffic-manager and all agents and, if a duration is given, it also starts a timer that will reset the log-level once it fires.

func (*State) UpdateIntercept

func (s *State) UpdateIntercept(interceptID string, apply func(*rpc.InterceptInfo)) *rpc.InterceptInfo

UpdateIntercept applies a given mutator function to the stored intercept with interceptID; storing and returning the result. If the given intercept does not exist, then the mutator function is not run, and nil is returned.

This does not lock; but instead uses CAS and may therefore call the mutator function multiple times. So: it is safe to perform blocking operations in your mutator function, but you must take care that it is safe to call your mutator function multiple times.

func (*State) WaitForTempLogLevel added in v2.4.2

func (s *State) WaitForTempLogLevel() *rpc.LogLevelRequest

WaitForTempLogLevel waits for a new temporary log-level request. It returns the values of the last request that was made.

func (*State) WatchAgents

func (s *State) WatchAgents(
	ctx context.Context,
	filter func(sessionID string, agent *rpc.AgentInfo) bool,
) <-chan watchable.AgentMapSnapshot

func (*State) WatchClients

func (s *State) WatchClients(
	ctx context.Context,
	filter func(sessionID string, client *rpc.ClientInfo) bool,
) <-chan watchable.ClientMapSnapshot

func (*State) WatchIntercepts

func (s *State) WatchIntercepts(
	ctx context.Context,
	filter func(sessionID string, intercept *rpc.InterceptInfo) bool,
) <-chan watchable.InterceptMapSnapshot

func (*State) WatchLookupHost added in v2.3.0

func (s *State) WatchLookupHost(agentSessionID string) <-chan *rpc.LookupHostRequest

Jump to

Keyboard shortcuts

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