reconnectingpty
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
Constants¶
const (// StateStarting is the default/start state. Attaching will block until the// reconnecting pty becomes ready.StateStarting =iota// StateReady means the reconnecting pty is ready to be attached.StateReady// StateClosing means the reconnecting pty has begun closing. The underlying// process may still be exiting. Attaching will result in an error.StateClosing// StateDone means the reconnecting pty has completely shut down and the// process has exited. Attaching will result in an error.StateDone)
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeOptions¶
type Options struct {// Timeout describes how long to keep the pty alive without any connections.// Once elapsed the pty will be killed.Timeouttime.Duration// Metrics tracks various error counters.Metrics *prometheus.CounterVec// BackendType specifies the ReconnectingPTY backend to use.BackendTypestring}
Options allows configuring the reconnecting pty.
typeReconnectingPTY¶
type ReconnectingPTY interface {// Attach pipes the connection and pty, spawning it if necessary, replays// history, then blocks until EOF, an error, or the context's end. The// connection is expected to send JSON-encoded messages and accept raw output// from the ptty. If the context ends or the process dies the connection will// be detached.Attach(ctxcontext.Context, connIDstring, connnet.Conn, height, widthuint16, loggerslog.Logger)error// Wait waits for the reconnecting pty to close. The underlying process might// still be exiting.Wait()// Close kills the reconnecting pty process.Close(errerror)}
ReconnectingPTY is a pty that can be reconnected within a timeout and tosimultaneous connections. The reconnecting pty can be backed by screen ifinstalled or a (buggy) buffer replay fallback.
funcNew¶
func New(ctxcontext.Context, loggerslog.Logger, execeragentexec.Execer, cmd *pty.Cmd, options *Options)ReconnectingPTY
New sets up a new reconnecting pty that wraps the provided command. Anyerrors with starting are returned on Attach(). The reconnecting pty willclose itself (and all connections to it) if nothing is attached for theduration of the timeout, if the context ends, or the process exits (bufferedbackend only).
typeServer¶added inv2.18.0
type Server struct {ExperimentalDevcontainersEnabledbool// contains filtered or unexported fields}
funcNewServer¶added inv2.18.0
func NewServer(loggerslog.Logger, commandCreator *agentssh.Server, reportConnection reportConnectionFunc,connectionsTotalprometheus.Counter, errorsTotal *prometheus.CounterVec,timeouttime.Duration, opts ...func(*Server),) *Server
NewServer returns a new ReconnectingPTY server