Documentation
¶
Overview ¶
Package terminal provides WebSocket-based terminal access to deployed service containers. **Validates: Requirements 23.1, 23.2**
Index ¶
- Variables
- func GenerateContainerName(appName, serviceName string, version int) string
- type Config
- type ControlMessage
- type Service
- func (s *Service) ActiveSessions() int
- func (s *Service) CloseSession(sessionID string) error
- func (s *Service) Connect(ctx context.Context, appID, serviceName string, conn *websocket.Conn) (*Session, error)
- func (s *Service) GetSession(sessionID string) (*Session, bool)
- func (s *Service) HandleSession(session *Session) error
- type Session
Constants ¶
This section is empty.
Variables ¶
var ( // ErrServiceNotRunning is returned when attempting to connect to a non-running service. ErrServiceNotRunning = errors.New("service is not running") // ErrContainerNotFound is returned when the container cannot be found. ErrContainerNotFound = errors.New("container not found") // ErrSessionClosed is returned when the terminal session is closed. ErrSessionClosed = errors.New("terminal session closed") )
Functions ¶
func GenerateContainerName ¶
GenerateContainerName creates a container name from app, service, and version. Format: {app}-{service}-v{version} **Validates: Requirements 9.3, 9.4, 9.5**
Types ¶
type Config ¶
type Config struct {
// DefaultShell is the shell to use when connecting to containers.
// Defaults to "/bin/sh" for BusyBox compatibility.
// **Validates: Requirements 23.6**
DefaultShell string
}
Config holds configuration for the terminal service.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default terminal service configuration.
type ControlMessage ¶
type ControlMessage struct {
Type string `json:"type"` // "resize" or "terminate"
Rows uint16 `json:"rows,omitempty"`
Cols uint16 `json:"cols,omitempty"`
}
ControlMessage represents a control message from the WebSocket client.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides terminal access to deployed containers. **Validates: Requirements 23.1, 23.2**
func NewService ¶
NewService creates a new terminal service.
func (*Service) ActiveSessions ¶
ActiveSessions returns the number of active terminal sessions.
func (*Service) CloseSession ¶
CloseSession closes a session by ID.
func (*Service) Connect ¶
func (s *Service) Connect(ctx context.Context, appID, serviceName string, conn *websocket.Conn) (*Session, error)
Connect establishes a terminal session to a container. **Validates: Requirements 23.1, 23.2**
func (*Service) GetSession ¶
GetSession returns an active session by ID.
func (*Service) HandleSession ¶
HandleSession manages the bidirectional communication for a terminal session. **Validates: Requirements 23.1, 23.2, 23.5**