Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect(url string, headers http.Header) error
- func (c *Client) GetDone() <-chan struct{}
- func (c *Client) GetError() error
- func (c *Client) GetExecID() string
- func (c *Client) GetMicroserviceUUID() string
- func (c *Client) IsConnected() bool
- func (c *Client) IsNormalClosure(err error) bool
- func (c *Client) ReadMessage() (*Message, error)
- func (c *Client) SendMessage(msg *Message) error
- func (c *Client) SetExecID(execID string)
- type Message
- type Session
- type SessionManager
Constants ¶
const ( MessageTypeStdin uint8 = 0 MessageTypeStdout uint8 = 1 MessageTypeStderr uint8 = 2 MessageTypeControl uint8 = 3 MessageTypeClose uint8 = 4 MessageTypeActivation uint8 = 5 )
Message types for WebSocket communication
const ( DefaultPingInterval = 30000 // 30 seconds DefaultPongTimeout = 10000 // 10 seconds DefaultMaxPayload = 1024 * 1024 // 1MB DefaultSessionTimeout = 300000 // 5 minutes DefaultCleanupInterval = 60000 // 1 minute DefaultMaxConnections = 10 )
WebSocket configuration constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a WebSocket client
func (*Client) GetDone ¶
func (c *Client) GetDone() <-chan struct{}
GetDone returns the done channel
func (*Client) GetMicroserviceUUID ¶
GetMicroserviceUUID returns the microservice UUID
func (*Client) IsConnected ¶
IsConnected checks if the client is connected
func (*Client) IsNormalClosure ¶ added in v1.4.4
IsNormalClosure checks if the error represents a normal session closure
func (*Client) ReadMessage ¶
ReadMessage reads a message from the server
func (*Client) SendMessage ¶
SendMessage sends a message to the server
type Message ¶
type Message struct {
Type uint8 `msgpack:"type"`
Data []byte `msgpack:"data"`
MicroserviceUUID string `msgpack:"microserviceUuid"`
ExecID string `msgpack:"execId"`
Timestamp int64 `msgpack:"timestamp"`
}
Message represents a WebSocket message with type and payload
func NewMessage ¶
NewMessage creates a new Message with the given type and payload
func (*Message) IsActivationMessage ¶
IsActivationMessage checks if the message is an activation message
func (*Message) IsCloseMessage ¶
IsCloseMessage checks if the message is a close message
func (*Message) IsControlMessage ¶
IsControlMessage checks if the message is a control message
func (*Message) IsStderrMessage ¶
IsStderrMessage checks if the message is a stderr message
func (*Message) IsStdinMessage ¶
IsStdinMessage checks if the message is a stdin message
func (*Message) IsStdoutMessage ¶
IsStdoutMessage checks if the message is a stdout message
type Session ¶
type Session struct {
ExecID string
MicroserviceUUID string
LastActivity time.Time
// contains filtered or unexported fields
}
Session represents a WebSocket session between a user and an agent
func NewSession ¶
NewSession creates a new Session with the given execID and microserviceUUID
func (*Session) UpdateActivity ¶
func (s *Session) UpdateActivity()
UpdateActivity updates the last activity timestamp
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager manages WebSocket sessions
func NewSessionManager ¶
func NewSessionManager() *SessionManager
NewSessionManager creates a new SessionManager
func (*SessionManager) AddSession ¶
func (sm *SessionManager) AddSession(session *Session)
AddSession adds a new session to the manager
func (*SessionManager) CleanupExpiredSessions ¶
func (sm *SessionManager) CleanupExpiredSessions(timeout time.Duration)
CleanupExpiredSessions removes all expired sessions
func (*SessionManager) GetActiveSessions ¶
func (sm *SessionManager) GetActiveSessions() int
GetActiveSessions returns the number of active sessions
func (*SessionManager) GetSession ¶
func (sm *SessionManager) GetSession(execID string) *Session
GetSession retrieves a session by its execID
func (*SessionManager) RemoveSession ¶
func (sm *SessionManager) RemoveSession(execID string)
RemoveSession removes a session by its execID