session

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package session 提供跨层共享的会话状态校验:exec 等进入容器的操作, 必须先确认会话存在、处于 running 且其 lease 仍处于活跃状态。

口径:GuardExec 是执行前置条件校验(状态机检查),不是会话归属授权模型—— 调用者身份边界由 daemon 鉴权(bearer token)承担;「哪个调用者拥有哪个 session」的归属授权属独立的产品级特性,本包不声称提供。补上状态校验的 意义:仅持有会话 id(如从日志/URL 泄露)不能对停滞会话执行命令。

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSessionNotFound 会话不存在 —— HTTP 语义 404 Not Found。
	ErrSessionNotFound = errors.New("session not found")
	// ErrSessionNotRunning 会话存在但未处于可执行状态(stopped/removed 或无容器)—— HTTP 语义 409 Conflict。
	ErrSessionNotRunning = errors.New("session is not running")
	// ErrLeaseInactive 会话背后的 lease 已终结或缺失 —— HTTP 语义 409 Conflict。
	ErrLeaseInactive = errors.New("session lease is no longer active")
)

语义化错误:HTTP/handler 层可按 errors.Is 映射 404/409;错误文本只描述会话状态, 不透出底层驱动细节(例如 sqlite 的 "sql: no rows in result set" 存在性 oracle)。

Functions

func GuardExec

func GuardExec(db *sql.DB, sessionID string) error

GuardExec 校验 sessionID 是否允许进入容器执行命令:会话必须存在且 status=running、 已绑定容器 id,且其 lease 处于活跃状态。任一条件不满足返回可判别的 sentinel 错误。

Types

This section is empty.

Jump to

Keyboard shortcuts

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