state

package
v2.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const AgentSessionIDPrefix = "agent:"
View Source
const RcodeNoAgents = 3841

RcodeNoAgents means that no agents replied to the DNS request.

View Source
const SessionConsumptionMetricsStaleTTL = 60 * time.Minute

SessionConsumptionMetricsStaleTTL is the duration after which we consider the metrics to be staled, meaning that they should not be updated anymore since the user doesn't really use Telepresence at the moment.

Variables

View Source
var NewStateFunc = NewState //nolint:gochecknoglobals // extension point

Functions

This section is empty.

Types

type InterceptFinalizer

type InterceptFinalizer func(ctx context.Context, interceptInfo *managerrpc.InterceptInfo) error

type SessionConsumptionMetrics added in v2.15.0

type SessionConsumptionMetrics struct {

	// data from client to the traffic manager.
	FromClientBytes *tunnel.CounterProbe
	// data from the traffic manager to the client.
	ToClientBytes *tunnel.CounterProbe
	// contains filtered or unexported fields
}

func NewSessionConsumptionMetrics added in v2.15.0

func NewSessionConsumptionMetrics() *SessionConsumptionMetrics

func (*SessionConsumptionMetrics) ConnectDuration added in v2.15.0

func (m *SessionConsumptionMetrics) ConnectDuration() time.Duration

func (*SessionConsumptionMetrics) LastUpdate added in v2.15.0

func (m *SessionConsumptionMetrics) LastUpdate() time.Time

func (*SessionConsumptionMetrics) SetConnectDuration added in v2.18.0

func (m *SessionConsumptionMetrics) SetConnectDuration(d time.Duration)

func (*SessionConsumptionMetrics) SetLastUpdate added in v2.18.0

func (m *SessionConsumptionMetrics) SetLastUpdate(t time.Time)

type SessionState

type SessionState interface {
	Active() bool
	Cancel()
	AwaitingBidiMapOwnerSessionID(stream tunnel.Stream) string
	Done() <-chan struct{}
	LastMarked() time.Time
	SetLastMarked(lastMarked time.Time)
	Dials() <-chan *rpc.DialRequest
	EstablishBidiPipe(context.Context, tunnel.Stream) (tunnel.Endpoint, error)
	OnConnect(context.Context, tunnel.Stream, *int32, *SessionConsumptionMetrics) (tunnel.Endpoint, error)
}

type State

type State interface {
	AddAgent(*rpc.AgentInfo, time.Time) string
	AddClient(*rpc.ClientInfo, time.Time) string
	AddIntercept(context.Context, string, string, *rpc.CreateInterceptRequest) (*rpc.ClientInfo, *rpc.InterceptInfo, error)
	AddInterceptFinalizer(string, InterceptFinalizer) error
	AddSessionConsumptionMetrics(metrics *rpc.TunnelMetrics)
	AgentsLookupDNS(context.Context, string, *rpc.DNSRequest) (dnsproxy.RRs, int, error)
	CountAgents() int
	CountClients() int
	CountIntercepts() int
	CountSessions() int
	CountTunnels() int
	CountTunnelIngress() uint64
	CountTunnelEgress() uint64
	ExpireSessions(context.Context, time.Time, time.Time)
	GetAgent(string) *rpc.AgentInfo
	GetActiveAgent(string) *rpc.AgentInfo
	GetAllClients() map[string]*rpc.ClientInfo
	GetClient(string) *rpc.ClientInfo
	GetSession(string) SessionState
	GetSessionConsumptionMetrics(string) *SessionConsumptionMetrics
	GetAllSessionConsumptionMetrics() map[string]*SessionConsumptionMetrics
	GetIntercept(string) (*rpc.InterceptInfo, bool)
	GetConnectCounter() *prometheus.CounterVec
	GetConnectActiveStatus() *prometheus.GaugeVec
	GetInterceptCounter() *prometheus.CounterVec
	GetInterceptActiveStatus() *prometheus.GaugeVec
	MarkSession(*rpc.RemainRequest, time.Time) bool
	NewInterceptInfo(string, *rpc.SessionInfo, *rpc.CreateInterceptRequest) *rpc.InterceptInfo
	PostLookupDNSResponse(context.Context, *rpc.DNSAgentResponse)
	EnsureAgent(context.Context, string, string) error
	PrepareIntercept(context.Context, *rpc.CreateInterceptRequest) (*rpc.PreparedIntercept, error)
	RemoveIntercept(context.Context, string)
	DropIntercept(string)
	RestoreAppContainer(context.Context, *rpc.InterceptInfo) error
	FinalizeIntercept(ctx context.Context, intercept *rpc.InterceptInfo)
	LoadMatchingIntercepts(filter func(string, *rpc.InterceptInfo) bool) map[string]*rpc.InterceptInfo
	RemoveSession(context.Context, string)
	SessionDone(string) (<-chan struct{}, error)
	SetTempLogLevel(context.Context, *rpc.LogLevelRequest)
	SetAllClientSessionsFinalizer(finalizer allClientSessionsFinalizer)
	SetAllInterceptsFinalizer(finalizer allInterceptsFinalizer)
	SetPrometheusMetrics(connectCounterVec *prometheus.CounterVec,
		connectStatusGaugeVec *prometheus.GaugeVec,
		interceptCounterVec *prometheus.CounterVec,
		interceptStatusGaugeVec *prometheus.GaugeVec)
	Tunnel(context.Context, tunnel.Stream) error
	UpdateIntercept(string, func(*rpc.InterceptInfo)) *rpc.InterceptInfo
	UpdateClient(sessionID string, apply func(*rpc.ClientInfo)) *rpc.ClientInfo
	RefreshSessionConsumptionMetrics(sessionID string)
	ValidateAgentImage(string, bool) error
	WaitForTempLogLevel(rpc.Manager_WatchLogLevelServer) error
	WatchAgents(context.Context, func(sessionID string, agent *rpc.AgentInfo) bool) <-chan watchable.Snapshot[*rpc.AgentInfo]
	WatchDial(sessionID string) <-chan *rpc.DialRequest
	WatchIntercepts(context.Context, func(sessionID string, intercept *rpc.InterceptInfo) bool) <-chan watchable.Snapshot[*rpc.InterceptInfo]
	WatchLookupDNS(string) <-chan *rpc.DNSRequest
}

func NewState

func NewState(ctx context.Context) State

Jump to

Keyboard shortcuts

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