wsconncache

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package wsconncache caches workspace agent connections by UUID. Deprecated: Use ServerTailnet instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentProvider added in v0.26.2

type AgentProvider struct {
	Cache *Cache
}

func (*AgentProvider) AgentConn added in v0.26.2

func (a *AgentProvider) AgentConn(_ context.Context, agentID uuid.UUID) (*codersdk.WorkspaceAgentConn, func(), error)

func (*AgentProvider) Close added in v0.26.2

func (a *AgentProvider) Close() error

func (*AgentProvider) ReverseProxy added in v0.26.2

func (a *AgentProvider) ReverseProxy(targetURL *url.URL, dashboardURL *url.URL, agentID uuid.UUID) (*httputil.ReverseProxy, func(), error)

type Cache

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

func New deprecated

func New(dialer Dialer, inactiveTimeout time.Duration) *Cache

New creates a new workspace connection cache that closes connections after the inactive timeout provided.

Agent connections are cached due to Wireguard negotiation taking a few hundred milliseconds, depending on latency.

Deprecated: Use coderd.NewServerTailnet instead. wsconncache is being phased out because it creates a unique Tailnet for each agent. See: https://github.com/coder/coder/issues/8218

func (*Cache) Acquire

func (c *Cache) Acquire(id uuid.UUID) (*Conn, func(), error)

Acquire gets or establishes a connection with the dialer using the ID provided. If a connection is in-progress, that connection or error will be returned.

The returned function is used to release a lock on the connection. Once zero locks exist on a connection, the inactive timeout will begin to tick down. After the time expires, the connection will be cleared from the cache.

func (*Cache) Close

func (c *Cache) Close() error

type Conn

type Conn struct {
	*codersdk.WorkspaceAgentConn
	// contains filtered or unexported fields
}

Conn wraps an agent connection with a reusable HTTP transport.

func (*Conn) Close added in v0.16.0

func (c *Conn) Close() error

Close ends the HTTP transport if exists, and closes the agent.

func (*Conn) HTTPTransport

func (c *Conn) HTTPTransport() *http.Transport

type Dialer

type Dialer func(id uuid.UUID) (*codersdk.WorkspaceAgentConn, error)

Dialer creates a new agent connection by ID.

Jump to

Keyboard shortcuts

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