wsproxysdk
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¶
- 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¶
typeClient¶
Client is a HTTP client for a subset of Coder API routes that externalproxies need.
func (*Client)CryptoKeys¶added inv2.16.0
func (c *Client) CryptoKeys(ctxcontext.Context, featurecodersdk.CryptoKeyFeature) (CryptoKeysResponse,error)
func (*Client)DeregisterWorkspaceProxy¶
func (c *Client) DeregisterWorkspaceProxy(ctxcontext.Context, reqDeregisterWorkspaceProxyRequest)error
func (*Client)DialWorkspaceAgent¶
func (c *Client) DialWorkspaceAgent(ctxcontext.Context, agentIDuuid.UUID, options *workspacesdk.DialAgentOptions) (agentConn *workspacesdk.AgentConn, errerror)
DialWorkspaceAgent calls the underlying codersdk.Client's DialWorkspaceAgentmethod.
func (*Client)IssueSignedAppToken¶
func (c *Client) IssueSignedAppToken(ctxcontext.Context, reqworkspaceapps.IssueTokenRequest) (IssueSignedAppTokenResponse,error)
IssueSignedAppToken issues a new signed app token for the provided apprequest. The error page will be returned as JSON. For use in externalproxies, use IssueSignedAppTokenHTML instead.
func (*Client)IssueSignedAppTokenHTML¶
func (c *Client) IssueSignedAppTokenHTML(ctxcontext.Context, rwhttp.ResponseWriter, reqworkspaceapps.IssueTokenRequest) (IssueSignedAppTokenResponse,bool)
IssueSignedAppTokenHTML issues a new signed app token for the provided apprequest. The error page will be returned as HTML in most cases, and will bewritten directly to the provided http.ResponseWriter.
func (*Client)RegisterWorkspaceProxy¶
func (c *Client) RegisterWorkspaceProxy(ctxcontext.Context, reqRegisterWorkspaceProxyRequest) (RegisterWorkspaceProxyResponse,error)
func (*Client)RegisterWorkspaceProxyLoop¶
func (c *Client) RegisterWorkspaceProxyLoop(ctxcontext.Context, optsRegisterWorkspaceProxyLoopOpts) (*RegisterWorkspaceProxyLoop,RegisterWorkspaceProxyResponse,error)
RegisterWorkspaceProxyLoop will register the workspace proxy and then start agoroutine to keep registering periodically in the background.
The first response is returned immediately, and subsequent responses will benotified to the given CallbackFn. When the loop is Close()d it will stopimmediately and an error will be returned to the FailureFn.
When a fatal error is encountered (or the proxy is closed), the proxy will bederegistered (with the same ReplicaID and AttemptTimeout) before calling theFailureFn.
func (*Client)ReportAppStats¶
func (c *Client) ReportAppStats(ctxcontext.Context, reqReportAppStatsRequest)error
ReportAppStats reports the given app stats to the primary coder server.
func (*Client)Request¶
func (c *Client) Request(ctxcontext.Context, method, pathstring, body interface{}, opts ...codersdk.RequestOption) (*http.Response,error)
Request wraps the underlying codersdk.Client's Request method.
func (*Client)RequestIgnoreRedirects¶
func (c *Client) RequestIgnoreRedirects(ctxcontext.Context, method, pathstring, body interface{}, opts ...codersdk.RequestOption) (*http.Response,error)
RequestIgnoreRedirects wraps the underlying codersdk.Client's Request methodon 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 returnedif the session token is not in the correct format for external proxies.
func (*Client)TailnetDialer¶added inv2.18.0
func (c *Client) TailnetDialer() (*workspacesdk.WebsocketDialer,error)
typeCoordinateMessage¶
type CoordinateMessage struct {TypeCoordinateMessageType `json:"type"`AgentIDuuid.UUID `json:"agent_id"`Node *agpl.Node `json:"node"`}
typeCoordinateMessageType¶
type CoordinateMessageTypeint
const (CoordinateMessageTypeSubscribeCoordinateMessageType = 1 +iotaCoordinateMessageTypeUnsubscribeCoordinateMessageTypeNodeUpdate)
typeCoordinateNodes¶
typeCryptoKeysResponse¶added inv2.16.0
typeIssueSignedAppTokenResponse¶
type IssueSignedAppTokenResponse struct {// SignedTokenStr should be set as a cookie on the response.SignedTokenStrstring `json:"signed_token_str"`}
typeRegisterWorkspaceProxyLoop¶added inv2.8.5
type RegisterWorkspaceProxyLoop struct {// contains filtered or unexported fields}
func (*RegisterWorkspaceProxyLoop)Close¶added inv2.8.5
func (l *RegisterWorkspaceProxyLoop) Close()
func (*RegisterWorkspaceProxyLoop)RegisterNow¶added inv2.8.5
func (l *RegisterWorkspaceProxyLoop) RegisterNow() (RegisterWorkspaceProxyResponse,error)
RegisterNow asks the registration loop to register immediately. A timeout of2x the attempt timeout is used to wait for the response.
func (*RegisterWorkspaceProxyLoop)Start¶added inv2.8.5
func (l *RegisterWorkspaceProxyLoop) Start(ctxcontext.Context) (RegisterWorkspaceProxyResponse,error)
Start starts the proxy registration loop. The provided context is only usedfor the initial registration. Use Close() to stop.
typeRegisterWorkspaceProxyLoopOpts¶
type RegisterWorkspaceProxyLoopOpts struct {Loggerslog.LoggerRequestRegisterWorkspaceProxyRequest// Interval between registration attempts. Defaults to 30 seconds. Note that// the initial registration is not delayed by this interval.Intervaltime.Duration// MaxFailureCount is the maximum amount of attempts that the loop will// retry registration before giving up. Defaults to 10 (for ~5 minutes).MaxFailureCountint// 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.AttemptTimeouttime.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(resRegisterWorkspaceProxyResponse)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(errerror)}
typeRegisterWorkspaceProxyRequest¶
type RegisterWorkspaceProxyRequest struct {// AccessURL that hits the workspace proxy api.AccessURLstring `json:"access_url"`// WildcardHostname that the workspace proxy api is serving for subdomain apps.WildcardHostnamestring `json:"wildcard_hostname"`// DerpEnabled indicates whether the proxy should be included in the DERP// map or not.DerpEnabledbool `json:"derp_enabled"`// DerpOnly indicates whether the proxy should only be included in the DERP// map and should not be used for serving apps.DerpOnlybool `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.ReplicaIDuuid.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.ReplicaHostnamestring `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.ReplicaErrorstring `json:"replica_error"`// ReplicaRelayAddress is the DERP address of the replica that other// replicas may use to connect internally for DERP meshing.ReplicaRelayAddressstring `json:"replica_relay_address"`// Version is the Coder version of the proxy.Versionstring `json:"version"`}
typeRegisterWorkspaceProxyResponse¶
type RegisterWorkspaceProxyResponse struct {DERPMeshKeystring `json:"derp_mesh_key"`DERPRegionIDint32 `json:"derp_region_id"`DERPMap *tailcfg.DERPMap `json:"derp_map"`DERPForceWebSocketsbool `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"`}
typeReportAppStatsRequest¶
type ReportAppStatsRequest struct {Stats []workspaceapps.StatsReport `json:"stats"`}