Help us shape the future of Go! Take the 2026 Go Developer Survey

session

package
v0.8.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start(ctx context.Context, command, workdir string, env []string, timeout time.Duration, prepare PrepareFunc) (*Session, PreparationStatus, error)

func StartCommandWithTTY

func StartCommandWithTTY(ctx context.Context, build CommandFactory, timeout time.Duration, tty bool, prepare PrepareFunc) (*Session, PreparationStatus, error)

func StartWithTTY

func StartWithTTY(ctx context.Context, command, workdir string, env []string, timeout time.Duration, tty bool, prepare PrepareFunc) (*Session, PreparationStatus, error)

Types

type CommandFactory

type CommandFactory func(context.Context) *exec.Cmd

type ExecutionContext

type ExecutionContext struct {
	Runtime      string
	Distribution string
	Workdir      string
}

type PreparationStatus added in v0.8.2

type PreparationStatus struct {
	Enabled  bool
	Mode     string
	Policy   string
	Warnings []string
}

type PrepareFunc

type PrepareFunc func(*exec.Cmd) (func(), PreparationStatus)

type Session

type Session struct {
	ID         string
	Command    *exec.Cmd
	Cancel     context.CancelFunc
	Stdin      io.WriteCloser
	StartedAt  time.Time
	FinishedAt time.Time
	Done       chan struct{}
	TimedOut   bool
	Terminal   string
	// contains filtered or unexported fields
}

func (*Session) CloseStdin

func (s *Session) CloseStdin() error

func (*Session) Completed

func (s *Session) Completed() bool

func (*Session) CompletedBefore

func (s *Session) CompletedBefore(cutoff time.Time) bool

func (*Session) Kill

func (s *Session) Kill() (bool, error)

func (*Session) Peek

func (s *Session) Peek(status string, maxBytes int) Snapshot

Peek returns the current unread output without advancing the observation cursors. Mutation tools use it so a following status call still receives the output.

func (*Session) SetExecutionContext

func (s *Session) SetExecutionContext(execution ExecutionContext)

func (*Session) Snapshot

func (s *Session) Snapshot(status string, maxBytes int) Snapshot

func (*Session) Summary

func (s *Session) Summary() Summary

func (*Session) WaitError

func (s *Session) WaitError() error

func (*Session) Write

func (s *Session) Write(text string) error

type Snapshot added in v0.8.2

type Snapshot struct {
	SessionID          string
	Status             string
	Stdout             string
	Stderr             string
	ElapsedMS          int64
	TimedOut           bool
	Terminal           string
	StdoutOutputBytes  int
	StderrOutputBytes  int
	StdoutTotalBytes   int
	StderrTotalBytes   int
	StdoutDroppedBytes int
	StderrDroppedBytes int
	StdoutOmittedBytes int
	StderrOmittedBytes int
	StdoutOutputLines  int
	StderrOutputLines  int
	StdoutTruncated    bool
	StderrTruncated    bool
	Completed          bool
	ExitCode           int
	CommandOK          bool
	Runtime            string
	WSLDistribution    string
	Workdir            string
}

type Store

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

func NewStore

func NewStore() *Store

func (*Store) Add

func (s *Store) Add(session *Session)

func (*Store) AddReserved

func (s *Store) AddReserved(session *Session)

func (*Store) BeginClose added in v0.8.1

func (s *Store) BeginClose()

func (*Store) Closing added in v0.8.1

func (s *Store) Closing() bool

func (*Store) Delete

func (s *Store) Delete(id string)

func (*Store) FinishStart added in v0.8.1

func (s *Store) FinishStart()

FinishStart 标记命令已经离开不可安全抢占的启动窗口。 调用方必须在 runner、进程控制器和取消监听都建立完成后调用。

func (*Store) Get

func (s *Store) Get(id string) (*Session, bool)

func (*Store) List

func (s *Store) List() []*Session

func (*Store) PruneCompletedBefore

func (s *Store) PruneCompletedBefore(cutoff time.Time) int

func (*Store) PruneCompletedToLimit

func (s *Store) PruneCompletedToLimit(limit int) int

func (*Store) ReleaseReservation

func (s *Store) ReleaseReservation()

func (*Store) ReservationCount

func (s *Store) ReservationCount() int

func (*Store) StartingCount added in v0.8.1

func (s *Store) StartingCount() int

func (*Store) TryReserve

func (s *Store) TryReserve(maxRunning int) bool

func (*Store) WaitForReservations added in v0.8.1

func (s *Store) WaitForReservations(ctx context.Context) bool

func (*Store) WaitForStarts added in v0.8.1

func (s *Store) WaitForStarts(ctx context.Context) bool

type Summary

type Summary struct {
	ID           string `json:"id"`
	Status       string `json:"status"`
	ElapsedMS    int64  `json:"elapsed_ms"`
	TimedOut     bool   `json:"timed_out"`
	Runtime      string `json:"runtime,omitempty"`
	Distribution string `json:"wsl_distribution,omitempty"`
	Workdir      string `json:"workdir,omitempty"`
}

Jump to

Keyboard shortcuts

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