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

session

package
v0.8.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandFactory

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

type ExecutionContext

type ExecutionContext struct {
	Runtime      string
	Distribution string
	Workdir      string
}

type PrepareFunc

type PrepareFunc func(*exec.Cmd) (func(), map[string]any)

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 Start

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

func StartCommandWithTTY

func StartCommandWithTTY(ctx context.Context, build CommandFactory, timeout time.Duration, tty bool, prepare PrepareFunc) (*Session, map[string]any, error)

func StartWithTTY

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

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) map[string]any

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) map[string]any

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 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