ws

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: BSD-3-Clause Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddProxiedPermissions added in v2.1.0

func AddProxiedPermissions(m *authz.PermissionMatcher)

AddProxiedPermissions registers the permissions required by proxied WebSocket routes with the environment proxy permission matcher. These streams are served by Echo (not Huma), so they are absent from the OpenAPI document and must be registered with the matcher separately. The paths are stored relative to /environments/{id} (i.e. prefixed with "/ws"), matching the resource suffix the proxy computes for forwarded requests.

func BuildDiagnostics

func BuildDiagnostics(diag *services.DiagnosticsService) systemtypes.Diagnostics

BuildDiagnostics assembles a full diagnostics snapshot: runtime/memory/GC from the DiagnosticsService plus this package's WebSocket metrics and worker-goroutine count. Shared by the REST endpoint (via handlers) and the live WebSocket stream.

func LogBroadcaster added in v2.4.0

func LogBroadcaster() *logs.Broadcaster

LogBroadcaster returns the backend-wide log broadcaster used by diagnostics.

func NewWebSocketHandler

func NewWebSocketHandler(
	group *echo.Group,
	projectService *services.ProjectService,
	containerService *services.ContainerService,
	swarmService *services.SwarmService,
	systemService *services.SystemService,
	diagnosticsService *services.DiagnosticsService,
	authMiddleware *middleware.AuthMiddleware,
	cfg *config.Config,
)

Types

type WebSocketHandler

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

WebSocketHandler consolidates all WebSocket and streaming endpoints. REST endpoints are handled by Huma handlers.

func (*WebSocketHandler) ContainerExec

func (h *WebSocketHandler) ContainerExec(c echo.Context) error

ContainerExec provides interactive terminal access to a container.

@Summary		Execute command in container via WebSocket
@Description	Interactive terminal access to a container over WebSocket
@Tags			WebSocket
@Param			id			path	string	true	"Environment ID"
@Param			containerId	path	string	true	"Container ID"
@Param			shell		query	string	false	"Shell to execute"	default(/bin/sh)
@Router			/api/environments/{id}/ws/containers/{containerId}/terminal [get]

func (*WebSocketHandler) ContainerLogs

func (h *WebSocketHandler) ContainerLogs(c echo.Context) error

ContainerLogs streams container logs over WebSocket.

@Summary		Get container logs via WebSocket
@Description	Stream container logs over WebSocket connection
@Tags			WebSocket
@Param			id			path	string	true	"Environment ID"
@Param			containerId	path	string	true	"Container ID"
@Param			follow		query	bool	false	"Follow log output"						default(true)
@Param			tail		query	string	false	"Number of lines to show from the end"	default(100)
@Param			since		query	string	false	"Show logs since timestamp"
@Param			timestamps	query	bool	false	"Show timestamps"				default(false)
@Param			format		query	string	false	"Output format (text or json)"	default(text)
@Param			batched		query	bool	false	"Batch log messages"			default(false)
@Router			/api/environments/{id}/ws/containers/{containerId}/logs [get]

func (*WebSocketHandler) ContainerStats

func (h *WebSocketHandler) ContainerStats(c echo.Context) error

ContainerStats streams container stats over WebSocket.

@Summary		Get container stats via WebSocket
@Description	Stream container resource statistics over WebSocket connection
@Tags			WebSocket
@Param			id			path	string	true	"Environment ID"
@Param			containerId	path	string	true	"Container ID"
@Router			/api/environments/{id}/ws/containers/{containerId}/stats [get]

func (*WebSocketHandler) DiagnosticsStream

func (h *WebSocketHandler) DiagnosticsStream(c echo.Context) error

DiagnosticsStream pushes a fresh diagnostics snapshot on connect and then every diagnosticsStreamInterval until the client disconnects.

func (*WebSocketHandler) ProjectLogs

func (h *WebSocketHandler) ProjectLogs(c echo.Context) error

ProjectLogs streams project logs over WebSocket.

@Summary		Get project logs via WebSocket
@Description	Stream project logs over WebSocket connection
@Tags			WebSocket
@Param			id			path	string	true	"Environment ID"
@Param			projectId	path	string	true	"Project ID"
@Param			follow		query	bool	false	"Follow log output"						default(true)
@Param			tail		query	string	false	"Number of lines to show from the end"	default(100)
@Param			since		query	string	false	"Show logs since timestamp"
@Param			timestamps	query	bool	false	"Show timestamps"				default(false)
@Param			format		query	string	false	"Output format (text or json)"	default(text)
@Param			batched		query	bool	false	"Batch log messages"			default(false)
@Router			/api/environments/{id}/ws/projects/{projectId}/logs [get]

func (*WebSocketHandler) ServerLogsStream

func (h *WebSocketHandler) ServerLogsStream(c echo.Context) error

ServerLogsStream replays the recent backend log backlog then streams new entries live.

func (*WebSocketHandler) ServiceLogs

func (h *WebSocketHandler) ServiceLogs(c echo.Context) error

ServiceLogs streams swarm service logs over WebSocket.

@Summary		Get swarm service logs via WebSocket
@Description	Stream swarm service logs over WebSocket connection
@Tags			WebSocket
@Param			id			path	string	true	"Environment ID"
@Param			serviceId	path	string	true	"Service ID"
@Param			follow		query	bool	false	"Follow log output"						default(true)
@Param			tail		query	string	false	"Number of lines to show from the end"	default(100)
@Param			since		query	string	false	"Show logs since timestamp"
@Param			timestamps	query	bool	false	"Show timestamps"				default(false)
@Param			format		query	string	false	"Output format (text or json)"	default(text)
@Param			batched		query	bool	false	"Batch log messages"			default(false)
@Router			/api/environments/{id}/ws/swarm/services/{serviceId}/logs [get]

func (*WebSocketHandler) SystemStats

func (h *WebSocketHandler) SystemStats(c echo.Context) error

SystemStats streams system stats over WebSocket.

@Summary		Get system stats via WebSocket
@Description	Stream system resource statistics over WebSocket connection
@Tags			WebSocket
@Param			id	path	string	true	"Environment ID"
@Router			/api/environments/{id}/ws/system/stats [get]

Jump to

Keyboard shortcuts

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