agent_server

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AGENT_SCHEDULE_INTERVAL       = 1 * time.Minute
	AGENT_LIVENESS_CHECK_INTERVAL = 10 * time.Second
	AGENT_LIVENESS_TIMEOUT        = 30 * time.Second
)
View Source
const (
	AGENT_SESSION_LOG_HISTORY = 1000 // Number of lines of log history to keep
)

Variables

This section is empty.

Functions

func DisconnectSession added in v0.25.0

func DisconnectSession(spaceId string, session *Session)

func ExpireSession added in v0.25.0

func ExpireSession(spaceId string, session *Session)

func GetPoolSessionState added in v0.28.0

func GetPoolSessionState(spaceId string) *service.PoolSessionState

func ListenAndServe

func ListenAndServe(listen string, tlsConfig *tls.Config)

func QueueSpaceReconcile added in v0.25.0

func QueueSpaceReconcile(spaceId string)

func RemoveSession

func RemoveSession(spaceId string)

Types

type Session

type Session struct {
	Id                    string
	Version               string
	HasCodeServer         bool
	SSHPort               int
	VNCHttpPort           int
	HasTerminal           bool
	TcpPorts              map[string]string
	HttpPorts             map[string]string
	HasVSCodeTunnel       bool
	VSCodeTunnelName      string
	CPUPercent            float64
	MemoryUsedBytes       uint64
	MemoryLimitBytes      uint64
	DiskUsedBytes         uint64
	DiskLimitBytes        uint64
	ActivityWriteCount    uint32
	ActivityCreateCount   uint32
	ActivityDeleteCount   uint32
	ActivityRenameCount   uint32
	ActivityDistinctPaths uint32
	LastActivityAtUnix    int64
	MethodCallsTotal      uint64
	HTTPRequestsTotal     uint64
	TCPConnectionsTotal   uint64
	MethodRPS             float64
	HTTPRPS               float64
	TCPRPS                float64
	LastStateAt           time.Time

	MuxSession *yamux.Session

	// The log history
	LogHistoryMutex *sync.RWMutex
	LogHistory      []*msg.LogMessage

	// The list of listeners for log messages
	LogListenersMutex *sync.RWMutex
	LogListeners      map[string]chan *msg.LogMessage
	// contains filtered or unexported fields
}

Struct holding the state / registration information of an agent

func GetSession

func GetSession(spaceId string) *Session

GetSession retrieves the agent session associated with the given spaceId. If an agent session is found for the provided spaceId, it returns the session; otherwise, it returns nil.

func NewSession

func NewSession(spaceId string, version string) *Session

creates a new agent session

func (*Session) CloseLogListeners added in v0.28.0

func (s *Session) CloseLogListeners()

CloseLogListeners closes and removes every registered log listener. Called when the session is torn down (e.g. the space terminated) so that streaming log readers unblock on their channel and close the client WebSocket — the same way the terminal closes when the mux session ends. Entries are deleted as they're closed so a concurrent UnregisterLogListener won't double-close.

func (*Session) GetLastStateAt added in v0.28.0

func (s *Session) GetLastStateAt() time.Time

GetLastStateAt returns the time of the last state report. LastStateAt is written by the agent state handler and the stale-session checker from different goroutines, so all access goes through these helpers.

func (*Session) Ping

func (s *Session) Ping() bool

func (*Session) RegisterLogListener added in v0.11.5

func (s *Session) RegisterLogListener() (string, chan *msg.LogMessage)

func (*Session) SendCallMethod added in v0.28.0

func (s *Session) SendCallMethod(call *msg.CallMethodRequest, timeoutSeconds int) (*msg.CallMethodResponse, error)

func (*Session) SendCallMethodBatch added in v0.28.0

func (s *Session) SendCallMethodBatch(req *msg.CallMethodBatchRequest, timeoutSeconds int) (*msg.CallMethodBatchResponse, error)

SendCallMethodBatch sends a sub-batch of calls to the agent in a single yamux stream. The agent processes each item concurrently through the method server and returns all responses in one CallMethodBatchResponse. Used by the server to forward batch items grouped by destination space.

func (*Session) SendCopyFile added in v0.19.0

func (s *Session) SendCopyFile(copyCmd *msg.CopyFileMessage) (chan *msg.CopyFileResponse, error)

func (*Session) SendExecuteScript added in v0.23.0

func (s *Session) SendExecuteScript(execMsg *msg.ExecuteScriptMessage) (chan *msg.ExecuteScriptResponse, error)

func (*Session) SendExecuteScriptStream added in v0.23.0

func (s *Session) SendExecuteScriptStream(execMsg *msg.ExecuteScriptStreamMessage) (io.ReadWriteCloser, error)

func (*Session) SendNotificationMethod added in v0.28.0

func (s *Session) SendNotificationMethod(call *msg.CallMethodRequest) error

SendNotificationMethod forwards a notification to the agent without waiting for a JSON-RPC response.

func (*Session) SendPortForward added in v0.22.2

func (s *Session) SendPortForward(portCmd *msg.PortForwardRequest) (*msg.PortForwardResponse, error)

func (*Session) SendPortList added in v0.22.2

func (s *Session) SendPortList() (*msg.PortListResponse, error)

func (*Session) SendPortStop added in v0.22.2

func (s *Session) SendPortStop(portCmd *msg.PortStopRequest) (*msg.PortStopResponse, error)

func (*Session) SendRunCommand added in v0.19.0

func (s *Session) SendRunCommand(runCmd *msg.RunCommandMessage) (chan *msg.RunCommandResponse, error)

func (*Session) SendUpdateAuthorizedKeys

func (s *Session) SendUpdateAuthorizedKeys(sshKeys []string, sshPrivateKey string, githubUsernames []string) error

func (*Session) SendUpdateHealthConfig added in v0.28.0

func (s *Session) SendUpdateHealthConfig(config *msg.HealthConfig) error

func (*Session) SendUpdateShell added in v0.11.5

func (s *Session) SendUpdateShell(shell string) error

func (*Session) SetLastStateAt added in v0.28.0

func (s *Session) SetLastStateAt(t time.Time)

SetLastStateAt records the time of the last state report.

func (*Session) UnregisterLogListener added in v0.11.5

func (s *Session) UnregisterLogListener(listenerId string)

Jump to

Keyboard shortcuts

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