agentsdk
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¶
- func StartupLogsNotifyChannel(agentID uuid.UUID) string
- func StartupLogsSender(patchStartupLogs func(ctx context.Context, req PatchStartupLogs) error, ...) (sendLog func(ctx context.Context, log ...StartupLog) error, ...)
- func StartupLogsWriter(ctx context.Context, sender func(ctx context.Context, log ...StartupLog) error, ...) io.WriteCloser
- type AWSInstanceIdentityToken
- type AgentMetric
- type AgentMetricLabel
- type AgentMetricType
- type AuthenticateResponse
- type AzureInstanceIdentityToken
- type Client
- func (c *Client) AuthAWSInstanceIdentity(ctx context.Context) (AuthenticateResponse, error)
- func (c *Client) AuthAzureInstanceIdentity(ctx context.Context) (AuthenticateResponse, error)
- func (c *Client) AuthGoogleInstanceIdentity(ctx context.Context, serviceAccount string, gcpClient *metadata.Client) (AuthenticateResponse, error)
- func (c *Client) GetServiceBanner(ctx context.Context) (codersdk.ServiceBannerConfig, error)
- func (c *Client) GitAuth(ctx context.Context, gitURL string, listen bool) (GitAuthResponse, error)
- func (c *Client) GitSSHKey(ctx context.Context) (GitSSHKey, error)
- func (c *Client) Listen(ctx context.Context) (net.Conn, error)
- func (c *Client) Manifest(ctx context.Context) (Manifest, error)
- func (c *Client) PatchStartupLogs(ctx context.Context, req PatchStartupLogs) error
- func (c *Client) PostAppHealth(ctx context.Context, req PostAppHealthsRequest) error
- func (c *Client) PostLifecycle(ctx context.Context, req PostLifecycleRequest) error
- func (c *Client) PostMetadata(ctx context.Context, key string, req PostMetadataRequest) error
- func (c *Client) PostStartup(ctx context.Context, req PostStartupRequest) error
- func (c *Client) PostStats(ctx context.Context, stats *Stats) (StatsResponse, error)
- func (c *Client) ReportStats(ctx context.Context, log slog.Logger, statsChan <-chan *Stats, ...) (io.Closer, error)
- func (c *Client) SetSessionToken(token string)
- type GitAuthResponse
- type GitSSHKey
- type GoogleInstanceIdentityToken
- type Manifest
- type PatchStartupLogs
- type PostAppHealthsRequest
- type PostLifecycleRequest
- type PostMetadataRequest
- type PostStartupRequest
- type StartupLog
- type StartupLogsNotifyMessage
- type Stats
- type StatsResponse
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcStartupLogsNotifyChannel¶added inv0.21.0
StartupLogsNotifyChannel returns the channel name responsible for notifyingof new startup logs.
funcStartupLogsSender¶added inv0.25.0
func StartupLogsSender(patchStartupLogs func(ctxcontext.Context, reqPatchStartupLogs)error, loggerslog.Logger) (sendLog func(ctxcontext.Context, log ...StartupLog)error, flushAndClose func(context.Context)error)
SendStartupLogs will send agent startup logs to the server. Calls tosendLog are non-blocking and will return an error if flushAndClosehas been called. Calling sendLog concurrently is not supported. Ifthe context passed to flushAndClose is canceled, any remaining logswill be discarded.
funcStartupLogsWriter¶added inv0.25.0
func StartupLogsWriter(ctxcontext.Context, sender func(ctxcontext.Context, log ...StartupLog)error, levelcodersdk.LogLevel)io.WriteCloser
StartupLogsWriter returns an io.WriteCloser that sends logs via theprovided sender. The sender is expected to be non-blocking. CallingClose flushes any remaining partially written log lines but isotherwise no-op. If the context passed to StartupLogsWriter iscanceled, any remaining logs will be discarded.
Neither Write nor Close is safe for concurrent use and must be usedby a single goroutine.
Types¶
typeAgentMetric¶added inv0.23.1
type AgentMetric struct {Namestring `json:"name" validate:"required"`TypeAgentMetricType `json:"type" validate:"required" enums:"counter,gauge"`Valuefloat64 `json:"value" validate:"required"`Labels []AgentMetricLabel `json:"labels,omitempty"`}
typeAgentMetricLabel¶added inv0.24.0
typeAgentMetricType¶added inv0.23.1
type AgentMetricTypestring
const (AgentMetricTypeCounterAgentMetricType = "counter"AgentMetricTypeGaugeAgentMetricType = "gauge")
typeAuthenticateResponse¶
type AuthenticateResponse struct {SessionTokenstring `json:"session_token"`}
AuthenticateResponse is returned when an instance IDhas been exchanged for a session token.@typescript-ignore AuthenticateResponse
typeClient¶
Client wraps `codersdk.Client` with specific functionsscoped to a workspace agent.
func (*Client)AuthAWSInstanceIdentity¶
func (c *Client) AuthAWSInstanceIdentity(ctxcontext.Context) (AuthenticateResponse,error)
AuthWorkspaceAWSInstanceIdentity uses the Amazon Metadata API tofetch a signed payload, and exchange it for a session token for a workspace agent.
The requesting instance must be registered as a resource in the latest history for a workspace.
func (*Client)AuthAzureInstanceIdentity¶
func (c *Client) AuthAzureInstanceIdentity(ctxcontext.Context) (AuthenticateResponse,error)
AuthWorkspaceAzureInstanceIdentity uses the Azure Instance Metadata Service tofetch a signed payload, and exchange it for a session token for a workspace agent.
func (*Client)AuthGoogleInstanceIdentity¶
func (c *Client) AuthGoogleInstanceIdentity(ctxcontext.Context, serviceAccountstring, gcpClient *metadata.Client) (AuthenticateResponse,error)
AuthWorkspaceGoogleInstanceIdentity uses the Google Compute Engine Metadata API tofetch a signed JWT, and exchange it for a session token for a workspace agent.
The requesting instance must be registered as a resource in the latest history for a workspace.
func (*Client)GetServiceBanner¶added inv0.25.0
GetServiceBanner relays the service banner config.
func (*Client)GitAuth¶
GitAuth submits a URL to fetch a GIT_ASKPASS username and password for.nolint:revive
func (*Client)Listen¶
Listen connects to the workspace agent coordinate WebSocketthat handles connection negotiation.
func (*Client)Manifest¶added inv0.21.3
Manifest fetches manifest for the currently authenticated workspace agent.
func (*Client)PatchStartupLogs¶added inv0.21.0
func (c *Client) PatchStartupLogs(ctxcontext.Context, reqPatchStartupLogs)error
PatchStartupLogs writes log messages to the agent startup script.Log messages are limited to 1MB in total.
func (*Client)PostAppHealth¶
func (c *Client) PostAppHealth(ctxcontext.Context, reqPostAppHealthsRequest)error
PostAppHealth updates the workspace agent app health status.
func (*Client)PostLifecycle¶
func (c *Client) PostLifecycle(ctxcontext.Context, reqPostLifecycleRequest)error
func (*Client)PostMetadata¶added inv0.21.3
func (*Client)PostStartup¶added inv0.17.1
func (c *Client) PostStartup(ctxcontext.Context, reqPostStartupRequest)error
func (*Client)ReportStats¶
func (c *Client) ReportStats(ctxcontext.Context, logslog.Logger, statsChan <-chan *Stats, setInterval func(time.Duration)) (io.Closer,error)
ReportStats begins a stat streaming connection with the Coder server.It is resilient to network failures and intermittent coderd issues.
func (*Client)SetSessionToken¶
typeGitAuthResponse¶
typeGoogleInstanceIdentityToken¶
type GoogleInstanceIdentityToken struct {JSONWebTokenstring `json:"json_web_token" validate:"required"`}
typeManifest¶added inv0.21.3
type Manifest struct {AgentIDuuid.UUID `json:"agent_id"`// GitAuthConfigs stores the number of Git configurations// the Coder deployment has. If this number is >0, we// set up special configuration in the workspace.GitAuthConfigsint `json:"git_auth_configs"`VSCodePortProxyURIstring `json:"vscode_port_proxy_uri"`Apps []codersdk.WorkspaceApp `json:"apps"`DERPMap *tailcfg.DERPMap `json:"derpmap"`EnvironmentVariables map[string]string `json:"environment_variables"`StartupScriptstring `json:"startup_script"`StartupScriptTimeouttime.Duration `json:"startup_script_timeout"`Directorystring `json:"directory"`MOTDFilestring `json:"motd_file"`ShutdownScriptstring `json:"shutdown_script"`ShutdownScriptTimeouttime.Duration `json:"shutdown_script_timeout"`DisableDirectConnectionsbool `json:"disable_direct_connections"`Metadata []codersdk.WorkspaceAgentMetadataDescription `json:"metadata"`}
typePatchStartupLogs¶added inv0.21.0
type PatchStartupLogs struct {Logs []StartupLog `json:"logs"`}
typePostAppHealthsRequest¶
type PostAppHealthsRequest struct {// Healths is a map of the workspace app name and the health of the app.Healths map[uuid.UUID]codersdk.WorkspaceAppHealth}
typePostLifecycleRequest¶
type PostLifecycleRequest struct {Statecodersdk.WorkspaceAgentLifecycle `json:"state"`ChangedAttime.Time `json:"changed_at"`}
typePostMetadataRequest¶added inv0.21.3
type PostMetadataRequest =codersdk.WorkspaceAgentMetadataResult
In the future, we may want to support sending back multiple values forperformance.
typePostStartupRequest¶added inv0.17.1
type PostStartupRequest struct {Versionstring `json:"version"`ExpandedDirectorystring `json:"expanded_directory"`Subsystemcodersdk.AgentSubsystem `json:"subsystem"`}
typeStartupLog¶added inv0.21.0
typeStartupLogsNotifyMessage¶added inv0.21.0
type StartupLogsNotifyMessage struct {CreatedAfterint64 `json:"created_after"`}
typeStats¶
type Stats struct {// ConnectionsByProto is a count of connections by protocol.ConnectionsByProto map[string]int64 `json:"connections_by_proto"`// ConnectionCount is the number of connections received by an agent.ConnectionCountint64 `json:"connection_count"`// ConnectionMedianLatencyMS is the median latency of all connections in milliseconds.ConnectionMedianLatencyMSfloat64 `json:"connection_median_latency_ms"`// RxPackets is the number of received packets.RxPacketsint64 `json:"rx_packets"`// RxBytes is the number of received bytes.RxBytesint64 `json:"rx_bytes"`// TxPackets is the number of transmitted bytes.TxPacketsint64 `json:"tx_packets"`// TxBytes is the number of transmitted bytes.TxBytesint64 `json:"tx_bytes"`// SessionCountVSCode is the number of connections received by an agent// that are from our VS Code extension.SessionCountVSCodeint64 `json:"session_count_vscode"`// SessionCountJetBrains is the number of connections received by an agent// that are from our JetBrains extension.SessionCountJetBrainsint64 `json:"session_count_jetbrains"`// SessionCountReconnectingPTY is the number of connections received by an agent// that are from the reconnecting web terminal.SessionCountReconnectingPTYint64 `json:"session_count_reconnecting_pty"`// SessionCountSSH is the number of connections received by an agent// that are normal, non-tagged SSH sessions.SessionCountSSHint64 `json:"session_count_ssh"`// Metrics collected by the agentMetrics []AgentMetric `json:"metrics"`}
Stats records the Agent's network connection statistics for use inuser-facing metrics and debugging.