Documentation ¶
Index ¶
- type Client
- func (c *Client) CryptoKeys(ctx context.Context, feature codersdk.CryptoKeyFeature) (CryptoKeysResponse, error)
- func (c *Client) DeregisterWorkspaceProxy(ctx context.Context, req DeregisterWorkspaceProxyRequest) error
- func (c *Client) DialWorkspaceAgent(ctx context.Context, agentID uuid.UUID, options *workspacesdk.DialAgentOptions) (agentConn *workspacesdk.AgentConn, err error)
- func (c *Client) IssueSignedAppToken(ctx context.Context, req workspaceapps.IssueTokenRequest) (IssueSignedAppTokenResponse, error)
- func (c *Client) IssueSignedAppTokenHTML(ctx context.Context, rw http.ResponseWriter, ...) (IssueSignedAppTokenResponse, bool)
- func (c *Client) RegisterWorkspaceProxy(ctx context.Context, req RegisterWorkspaceProxyRequest) (RegisterWorkspaceProxyResponse, error)
- func (c *Client) RegisterWorkspaceProxyLoop(ctx context.Context, opts RegisterWorkspaceProxyLoopOpts) (*RegisterWorkspaceProxyLoop, RegisterWorkspaceProxyResponse, error)
- func (c *Client) ReportAppStats(ctx context.Context, req ReportAppStatsRequest) error
- func (c *Client) Request(ctx context.Context, method, path string, body interface{}, ...) (*http.Response, error)
- func (c *Client) RequestIgnoreRedirects(ctx context.Context, method, path string, body interface{}, ...) (*http.Response, error)
- func (c *Client) SessionToken() string
- func (c *Client) SetSessionToken(token string) error
- func (c *Client) TailnetDialer() (*workspacesdk.WebsocketDialer, error)
- type CoordinateMessage
- type CoordinateMessageType
- type CoordinateNodes
- type CryptoKeysResponse
- type DeregisterWorkspaceProxyRequest
- type IssueSignedAppTokenResponse
- type RegisterWorkspaceProxyLoop
- type RegisterWorkspaceProxyLoopOpts
- type RegisterWorkspaceProxyRequest
- type RegisterWorkspaceProxyResponse
- type ReportAppStatsRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a HTTP client for a subset of Coder API routes that external proxies need.
func (*Client) CryptoKeys ¶ added in v2.16.0
func (c *Client) CryptoKeys(ctx context.Context, feature codersdk.CryptoKeyFeature) (CryptoKeysResponse, error)
func (*Client) DeregisterWorkspaceProxy ¶
func (c *Client) DeregisterWorkspaceProxy(ctx context.Context, req DeregisterWorkspaceProxyRequest) error
func (*Client) DialWorkspaceAgent ¶
func (c *Client) DialWorkspaceAgent(ctx context.Context, agentID uuid.UUID, options *workspacesdk.DialAgentOptions) (agentConn *workspacesdk.AgentConn, err error)
DialWorkspaceAgent calls the underlying codersdk.Client's DialWorkspaceAgent method.
func (*Client) IssueSignedAppToken ¶
func (c *Client) IssueSignedAppToken(ctx context.Context, req workspaceapps.IssueTokenRequest) (IssueSignedAppTokenResponse, error)
IssueSignedAppToken issues a new signed app token for the provided app request. The error page will be returned as JSON. For use in external proxies, use IssueSignedAppTokenHTML instead.
func (*Client) IssueSignedAppTokenHTML ¶
func (c *Client) IssueSignedAppTokenHTML(ctx context.Context, rw http.ResponseWriter, req workspaceapps.IssueTokenRequest) (IssueSignedAppTokenResponse, bool)
IssueSignedAppTokenHTML issues a new signed app token for the provided app request. The error page will be returned as HTML in most cases, and will be written directly to the provided http.ResponseWriter.
func (*Client) RegisterWorkspaceProxy ¶
func (c *Client) RegisterWorkspaceProxy(ctx context.Context, req RegisterWorkspaceProxyRequest) (RegisterWorkspaceProxyResponse, error)
func (*Client) RegisterWorkspaceProxyLoop ¶
func (c *Client) RegisterWorkspaceProxyLoop(ctx context.Context, opts RegisterWorkspaceProxyLoopOpts) (*RegisterWorkspaceProxyLoop, RegisterWorkspaceProxyResponse, error)
RegisterWorkspaceProxyLoop will register the workspace proxy and then start a goroutine to keep registering periodically in the background.
The first response is returned immediately, and subsequent responses will be notified to the given CallbackFn. When the loop is Close()d it will stop immediately and an error will be returned to the FailureFn.
When a fatal error is encountered (or the proxy is closed), the proxy will be deregistered (with the same ReplicaID and AttemptTimeout) before calling the FailureFn.
func (*Client) ReportAppStats ¶
func (c *Client) ReportAppStats(ctx context.Context, req ReportAppStatsRequest) error
ReportAppStats reports the given app stats to the primary coder server.
func (*Client) Request ¶
func (c *Client) Request(ctx context.Context, method, path string, body interface{}, opts ...codersdk.RequestOption) (*http.Response, error)
Request wraps the underlying codersdk.Client's Request method.
func (*Client) RequestIgnoreRedirects ¶
func (c *Client) RequestIgnoreRedirects(ctx context.Context, method, path string, body interface{}, opts ...codersdk.RequestOption) (*http.Response, error)
RequestIgnoreRedirects wraps the underlying codersdk.Client's Request method on the client that ignores redirects.
func (*Client) SessionToken ¶
SessionToken returns the currently set token for the client.
func (*Client) SetSessionToken ¶
SetSessionToken sets the session token for the client. An error is returned if the session token is not in the correct format for external proxies.
func (*Client) TailnetDialer ¶ added in v2.18.0
func (c *Client) TailnetDialer() (*workspacesdk.WebsocketDialer, error)
type CoordinateMessage ¶
type CoordinateMessage struct { Type CoordinateMessageType `json:"type"` AgentID uuid.UUID `json:"agent_id"` Node *agpl.Node `json:"node"` }
type CoordinateMessageType ¶
type CoordinateMessageType int
const ( CoordinateMessageTypeSubscribe CoordinateMessageType = 1 + iota CoordinateMessageTypeUnsubscribe CoordinateMessageTypeNodeUpdate )
type CoordinateNodes ¶
type CryptoKeysResponse ¶ added in v2.16.0
type IssueSignedAppTokenResponse ¶
type IssueSignedAppTokenResponse struct { // SignedTokenStr should be set as a cookie on the response. SignedTokenStr string `json:"signed_token_str"` }
type RegisterWorkspaceProxyLoop ¶ added in v2.8.5
type RegisterWorkspaceProxyLoop struct {
// contains filtered or unexported fields
}
func (*RegisterWorkspaceProxyLoop) Close ¶ added in v2.8.5
func (l *RegisterWorkspaceProxyLoop) Close()
func (*RegisterWorkspaceProxyLoop) RegisterNow ¶ added in v2.8.5
func (l *RegisterWorkspaceProxyLoop) RegisterNow() (RegisterWorkspaceProxyResponse, error)
RegisterNow asks the registration loop to register immediately. A timeout of 2x the attempt timeout is used to wait for the response.
func (*RegisterWorkspaceProxyLoop) Start ¶ added in v2.8.5
func (l *RegisterWorkspaceProxyLoop) Start(ctx context.Context) (RegisterWorkspaceProxyResponse, error)
Start starts the proxy registration loop. The provided context is only used for the initial registration. Use Close() to stop.
type RegisterWorkspaceProxyLoopOpts ¶
type RegisterWorkspaceProxyLoopOpts struct { Logger slog.Logger Request RegisterWorkspaceProxyRequest // Interval between registration attempts. Defaults to 30 seconds. Note that // the initial registration is not delayed by this interval. Interval time.Duration // MaxFailureCount is the maximum amount of attempts that the loop will // retry registration before giving up. Defaults to 10 (for ~5 minutes). MaxFailureCount int // AttemptTimeout is the maximum amount of time that the loop will wait for // a response from the server before considering the attempt a failure. // Defaults to 10 seconds. AttemptTimeout time.Duration // MutateFn is called before each request to mutate the request struct. This // can be used to update fields like ReplicaError. MutateFn func(req *RegisterWorkspaceProxyRequest) // CallbackFn is called with the response from the server after each // successful registration, except the first. The callback function is // called in a blocking manner, so it should avoid blocking for too long. If // the callback returns an error, the loop will stop immediately and the // error will be returned to the FailureFn. CallbackFn func(res RegisterWorkspaceProxyResponse) error // FailureFn is called with the last error returned from the server if the // context is canceled, registration fails for more than MaxFailureCount, // or if any permanent values in the response change. FailureFn func(err error) }
type RegisterWorkspaceProxyRequest ¶
type RegisterWorkspaceProxyRequest struct { // AccessURL that hits the workspace proxy api. AccessURL string `json:"access_url"` // WildcardHostname that the workspace proxy api is serving for subdomain apps. WildcardHostname string `json:"wildcard_hostname"` // DerpEnabled indicates whether the proxy should be included in the DERP // map or not. DerpEnabled bool `json:"derp_enabled"` // DerpOnly indicates whether the proxy should only be included in the DERP // map and should not be used for serving apps. DerpOnly bool `json:"derp_only"` // ReplicaID is a unique identifier for the replica of the proxy that is // registering. It should be generated by the client on startup and // persisted (in memory only) until the process is restarted. ReplicaID uuid.UUID `json:"replica_id"` // ReplicaHostname is the OS hostname of the machine that the proxy is running // on. This is only used for tracking purposes in the replicas table. ReplicaHostname string `json:"hostname"` // ReplicaError is the error that the replica encountered when trying to // dial it's peers. This is stored in the replicas table for debugging // purposes but does not affect the proxy's ability to register. // // This value is only stored on subsequent requests to the register // endpoint, not the first request. ReplicaError string `json:"replica_error"` // ReplicaRelayAddress is the DERP address of the replica that other // replicas may use to connect internally for DERP meshing. ReplicaRelayAddress string `json:"replica_relay_address"` // Version is the Coder version of the proxy. Version string `json:"version"` }
type RegisterWorkspaceProxyResponse ¶
type RegisterWorkspaceProxyResponse struct { DERPMeshKey string `json:"derp_mesh_key"` DERPRegionID int32 `json:"derp_region_id"` DERPMap *tailcfg.DERPMap `json:"derp_map"` DERPForceWebSockets bool `json:"derp_force_websockets"` // SiblingReplicas is a list of all other replicas of the proxy that have // not timed out. SiblingReplicas []codersdk.Replica `json:"sibling_replicas"` }
type ReportAppStatsRequest ¶
type ReportAppStatsRequest struct {
Stats []workspaceapps.StatsReport `json:"stats"`
}