Documentation
¶
Index ¶
Constants ¶
const MaxBufferBytes = 1 << 20 // 1 MiB
MaxBufferBytes is the per-session cap on accumulated stdout+stderr. Anything beyond this is truncated from the head of the ring; the session records how many bytes were lost so the SDK can warn.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chunk ¶
type Chunk struct {
Stream string `json:"stream"` // "stdout" or "stderr"
Data []byte `json:"-"`
Seq int `json:"seq"`
}
Chunk is one stdout or stderr segment delivered to the SDK. Seq is monotonically increasing per-session starting at 1; the SDK passes the highest Seq it has seen as the `since` query param to get only newer chunks.
type Manager ¶
Manager owns the in-process session table. Call Run() at startup to spawn the background goroutine that calls Sweep() every minute; sessions inactive for IdleTimeout are dropped (the SDK polling stops returning their output and the session ID goes 404).
func NewManager ¶
type Session ¶
Session is one long-running process spawned via tools.UnifiedExec / exec_command. The SDK polls Output, writes stdin, and terminates via the corresponding /api/sdk/processes/{sid}/* endpoints.
func (*Session) Append ¶
Append adds a chunk and updates lastActivity. Old chunks are dropped from the head when the total exceeds MaxBufferBytes; the dropped bytes are accumulated into lostBytes so the SDK can warn.
func (*Session) LastActivity ¶
LastActivity is the time of the most recent Append / SetExit.
func (*Session) LostBytes ¶
LostBytes is the total bytes dropped from the head of the ring after the buffer hit MaxBufferBytes. Reset to 0 on a fresh session.
func (*Session) OutputSince ¶
OutputSince returns every chunk whose Seq > since, plus the current exit code (nil if still running) and an alive flag.