Movatterモバイル変換


[0]ホーム

URL:


wsproxysdk

package
v2.23.0Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License:AGPL-3.0Imports:16Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeClient

type Client struct {SDKClient *codersdk.Client// contains filtered or unexported fields}

Client is a HTTP client for a subset of Coder API routes that externalproxies need.

funcNew

func New(serverURL *url.URL) *Client

New creates a external proxy client for the provided primary coder serverURL.

func (*Client)CryptoKeysadded inv2.16.0

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

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

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)RegisterWorkspaceProxyLoop

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

func (c *Client) SessionToken()string

SessionToken returns the currently set token for the client.

func (*Client)SetSessionToken

func (c *Client) SetSessionToken(tokenstring)error

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)TailnetDialeradded 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

type CoordinateNodes struct {Nodes []*agpl.Node}

typeCryptoKeysResponseadded inv2.16.0

type CryptoKeysResponse struct {CryptoKeys []codersdk.CryptoKey `json:"crypto_keys"`}

typeDeregisterWorkspaceProxyRequest

type DeregisterWorkspaceProxyRequest struct {// ReplicaID is a unique identifier for the replica of the proxy that is// deregistering. It should be generated by the client on startup and// should've already been passed to the register endpoint.ReplicaIDuuid.UUID `json:"replica_id"`}

typeIssueSignedAppTokenResponse

type IssueSignedAppTokenResponse struct {// SignedTokenStr should be set as a cookie on the response.SignedTokenStrstring `json:"signed_token_str"`}

typeRegisterWorkspaceProxyLoopadded inv2.8.5

type RegisterWorkspaceProxyLoop struct {// contains filtered or unexported fields}

func (*RegisterWorkspaceProxyLoop)Closeadded inv2.8.5

func (l *RegisterWorkspaceProxyLoop) Close()

func (*RegisterWorkspaceProxyLoop)RegisterNowadded inv2.8.5

RegisterNow asks the registration loop to register immediately. A timeout of2x the attempt timeout is used to wait for the response.

func (*RegisterWorkspaceProxyLoop)Startadded inv2.8.5

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"`}

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp