Thanks to visit codestin.com
Credit goes to pkg.go.dev

agent

package
v2.21.3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: AGPL-3.0 Imports: 60 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolReconnectingPTY = "reconnecting-pty"
	ProtocolSSH             = "ssh"
	ProtocolDial            = "dial"
)
View Source
const (
	EnvProcPrioMgmt = "CODER_PROC_PRIO_MGMT"
	EnvProcOOMScore = "CODER_PROC_OOM_SCORE"
)

EnvProcPrioMgmt determines whether we attempt to manage process CPU and OOM Killer priority.

View Source
const EnvAgentSubsystem = "CODER_AGENT_SUBSYSTEM"

EnvAgentSubsystem is the environment variable used to denote the specialized environment in which the agent is running (e.g. envbox, envbuilder).

Variables

View Source
var WindowsDriveRegex = regexp.MustCompile(`^[a-zA-Z]:\\$`)

Functions

func PrometheusMetricsHandler added in v2.10.0

func PrometheusMetricsHandler(prometheusRegistry *prometheus.Registry, logger slog.Logger) http.Handler

func WorkspaceKeySeed added in v2.20.0

func WorkspaceKeySeed(workspaceID uuid.UUID, agentName string) (int64, error)

WorkspaceKeySeed converts a WorkspaceID UUID and agent name to an int64 hash. This uses the FNV-1a hash algorithm which provides decent distribution and collision resistance for string inputs.

Types

type Agent

type Agent interface {
	HTTPDebug() http.Handler
	// TailnetConn may be nil.
	TailnetConn() *tailnet.Conn
	io.Closer
}

func New

func New(options Options) Agent

type Client

type Client interface {
	ConnectRPC24(ctx context.Context) (
		proto.DRPCAgentClient24, tailnetproto.DRPCTailnetClient24, error,
	)
	RewriteDERPMap(derpMap *tailcfg.DERPMap)
}

type LSFile added in v2.21.0

type LSFile struct {
	Name string `json:"name"`
	// e.g. "C:\\Users\\coder\\hello.txt"
	//      "/home/coder/hello.txt"
	AbsolutePathString string `json:"absolute_path_string"`
	IsDir              bool   `json:"is_dir"`
}

type LSRelativity added in v2.21.0

type LSRelativity string
const (
	LSRelativityRoot LSRelativity = "root"
	LSRelativityHome LSRelativity = "home"
)

type LSRequest added in v2.21.0

type LSRequest struct {
	// e.g. [], ["repos", "coder"],
	Path []string `json:"path"`
	// Whether the supplied path is relative to the user's home directory,
	// or the root directory.
	Relativity LSRelativity `json:"relativity"`
}

type LSResponse added in v2.21.0

type LSResponse struct {
	AbsolutePath []string `json:"absolute_path"`
	// Returned so clients can display the full path to the user, and
	// copy it to configure file sync
	// e.g. Windows: "C:\\Users\\coder"
	//      Linux: "/home/coder"
	AbsolutePathString string   `json:"absolute_path_string"`
	Contents           []LSFile `json:"contents"`
}

type Options

type Options struct {
	Filesystem                   afero.Fs
	LogDir                       string
	TempDir                      string
	ScriptDataDir                string
	ExchangeToken                func(ctx context.Context) (string, error)
	Client                       Client
	ReconnectingPTYTimeout       time.Duration
	EnvironmentVariables         map[string]string
	Logger                       slog.Logger
	IgnorePorts                  map[int]string
	PortCacheDuration            time.Duration
	SSHMaxTimeout                time.Duration
	TailnetListenPort            uint16
	Subsystems                   []codersdk.AgentSubsystem
	PrometheusRegistry           *prometheus.Registry
	ReportMetadataInterval       time.Duration
	ServiceBannerRefreshInterval time.Duration
	BlockFileTransfer            bool
	Execer                       agentexec.Execer
	ContainerLister              agentcontainers.Lister

	ExperimentalDevcontainersEnabled bool
}

type PostWorkspaceAgentAppHealth

type PostWorkspaceAgentAppHealth func(context.Context, agentsdk.PostAppHealthsRequest) error

PostWorkspaceAgentAppHealth updates the workspace app health.

type WorkspaceAppHealthReporter

type WorkspaceAppHealthReporter func(ctx context.Context)

WorkspaceAppHealthReporter is a function that checks and reports the health of the workspace apps until the passed context is canceled.

func NewAppHealthReporterWithClock added in v2.13.0

func NewAppHealthReporterWithClock(
	logger slog.Logger,
	apps []codersdk.WorkspaceApp,
	postWorkspaceAgentAppHealth PostWorkspaceAgentAppHealth,
	clk quartz.Clock,
) WorkspaceAppHealthReporter

NewAppHealthReporterWithClock is only called directly by test code. Product code should call NewAppHealthReporter.

func NewWorkspaceAppHealthReporter

func NewWorkspaceAppHealthReporter(logger slog.Logger, apps []codersdk.WorkspaceApp, postWorkspaceAgentAppHealth PostWorkspaceAgentAppHealth) WorkspaceAppHealthReporter

NewWorkspaceAppHealthReporter creates a WorkspaceAppHealthReporter that reports app health to coderd.

Directories

Path Synopsis
acmock
Package acmock is a generated GoMock package.
Package acmock is a generated GoMock package.
dcspec
Code generated by dcspec/gen.sh.
Code generated by dcspec/gen.sh.
Package reaper contains logic for reaping subprocesses.
Package reaper contains logic for reaping subprocesses.

Jump to

Keyboard shortcuts

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