Help us shape the future of Go! Take the 2026 Go Developer Survey

tunnelserver

package
v1.27.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MPL-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(options ...Option) *tunnelServer

func NewStreamReader

func NewStreamReader(stream tunnel.Tunnel_StreamWorkspaceClient) io.Reader

NewStreamReader adapts stream into an io.Reader. A non-EOF error from stream.Recv() propagates to the reader via CloseWithError rather than being silently converted to a clean io.EOF: masking it as EOF would let a mid-stream failure (e.g. a dropped gRPC connection) look like a successful, but truncated, transfer to whatever is consuming the reader (extract.Extract for StreamWorkspace/StreamMount, and the snapshot volumes blob push). This is shared by every Tunnel_StreamWorkspaceClient consumer, not just snapshots - see stream_test.go for coverage of both.

func NewStreamWriter

func NewStreamWriter(stream tunnel.Tunnel_StreamWorkspaceServer) io.Writer

func NewTunnelClient

func NewTunnelClient(
	reader io.Reader,
	writer io.WriteCloser,
) (tunnel.TunnelClient, error)

func NewTunnelStatusReporter added in v1.13.0

func NewTunnelStatusReporter(ctx context.Context, client tunnel.TunnelClient) status.Reporter

NewTunnelStatusReporter returns a status.Reporter that forwards each event to client over the Status RPC, mirroring NewTunnelLogger's buffered-worker pattern so a slow/unavailable peer cannot stall the up pipeline.

func ReportResult added in v1.15.0

func ReportResult(
	ctx context.Context,
	tunnelClient tunnel.TunnelClient,
	fn func(ctx context.Context) (*config.Result, error),
) (*config.Result, error)

ReportResult runs fn and guarantees its outcome is sent over the tunnel via SendResult exactly once before returning, whether fn succeeds or fails.

func RunServicesServer

func RunServicesServer(ctx context.Context, spec ServicesSpec) error

func RunSetupServer

func RunSetupServer(ctx context.Context, spec SetupSpec) (*config.Result, error)

func RunUpServer

func RunUpServer(ctx context.Context, spec UpSpec) (*config.Result, error)

func WithSetupLogOptions

func WithSetupLogOptions(ctx context.Context, opts []Option) context.Context

WithSetupLogOptions carries tunnel server options for setup history to code that starts the server several calls down.

Types

type HopOptions

type HopOptions struct {
	// Session is this process's run session.
	Session *workspacelogs.Session
	// Upstream is the client of the next host. Nil makes the hop receive-only.
	Upstream tunnel.TunnelClient
	// Receive accepts records mirrored from the previous host.
	Receive bool
}

HopOptions selects what a hop does.

type Logger added in v1.1.0

type Logger interface {
	Debugf(format string, args ...any)
	Info(args ...any)
	Infof(format string, args ...any)
	Warnf(format string, args ...any)
}

Logger is the minimal logging interface used by workspace initialization. It is implemented by tunnelLogger, which sends log messages through the tunnel protocol back to the client.

func NewTunnelLogger

func NewTunnelLogger(ctx context.Context, client tunnel.TunnelClient, debug bool) Logger

type Option

type Option func(*tunnelServer) *tunnelServer

func SetupLogOptionsFrom

func SetupLogOptionsFrom(ctx context.Context) []Option

SetupLogOptionsFrom returns the options stored by WithSetupLogOptions.

func WithAllowDockerCredentials

func WithAllowDockerCredentials(allowDockerCredentials bool) Option

func WithAllowGitCredentials

func WithAllowGitCredentials(allowGitCredentials bool) Option

func WithAllowGitHubCredentials added in v1.25.0

func WithAllowGitHubCredentials(allow bool) Option

func WithAllowKubeConfig

func WithAllowKubeConfig(allow bool) Option

func WithForwarder

func WithForwarder(forwarder netstat.Forwarder) Option

func WithGitSSHSigningKey added in v1.25.0

func WithGitSSHSigningKey(signingKey string) Option

WithGitSSHSigningKey configures the host Git SSH signing key for fallback resolution.

func WithGitToken added in v1.10.0

func WithGitToken(token *provider2.GitToken) Option

func WithMounts

func WithMounts(mounts []*config.Mount) Option

func WithPlatformOptions

func WithPlatformOptions(options *devsy.PlatformOptions) Option

func WithSecrets added in v1.10.0

func WithSecrets(env, mount []string) Option

func WithSetupLogSink

func WithSetupLogSink(sink *workspacelogs.Sink) Option

WithSetupLogSink accepts AppendSetupLogs batches for the sink's expected run. A nil sink leaves the RPC unimplemented, which senders treat as an old peer.

func WithSnapshotBuildContext added in v1.23.1

func WithSnapshotBuildContext(context string) Option

WithSnapshotBuildContext identifies generated residue to exclude, never upload authority.

func WithStatusReporter added in v1.13.0

func WithStatusReporter(reporter status.Reporter) Option

WithStatusReporter forwards inbound StatusUpdate RPCs to reporter. A nil reporter is ignored, since it would replace the Nop default and panic.

func WithWorkspace

func WithWorkspace(workspace *provider2.Workspace) Option

func WithWorkspaceMount added in v1.23.1

func WithWorkspaceMount(mount *config.Mount) Option

WithWorkspaceMount limits workspace ignore rules to this mount.

type ServicesSpec

type ServicesSpec struct {
	Reader                 io.Reader
	Writer                 io.WriteCloser
	AllowGitCredentials    bool
	AllowDockerCredentials bool
	Forwarder              netstat.Forwarder
	Workspace              *provider2.Workspace
	Options                []Option
}

ServicesSpec configures RunServicesServer.

type SetupLogHop

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

SetupLogHop wires one process's side of setup history mirroring: it sends this process's own records to the next host, accepts records mirrored from the previous host, and forwards those on. Every method is safe on a nil hop, so a process without history changes nothing.

func NewSetupLogHop

func NewSetupLogHop(ctx context.Context, opts HopOptions) *SetupLogHop

NewSetupLogHop builds the hop. It returns nil when the session is nil or the hop would do nothing.

func (*SetupLogHop) Close

func (h *SetupLogHop) Close()

Close stops the background senders.

func (*SetupLogHop) Flush

func (h *SetupLogHop) Flush(ctx context.Context) bool

Flush drains everything upstream within the senders' own cleanup budget, even when ctx is already canceled. It reports whether the next host holds everything. Call it after the session is finished and before the result is reported.

func (*SetupLogHop) Options

func (h *SetupLogHop) Options() []Option

Options returns the tunnel server option that accepts mirrored records.

type SetupSpec

type SetupSpec struct {
	Reader                 io.Reader
	Writer                 io.WriteCloser
	AllowGitCredentials    bool
	AllowDockerCredentials bool
	SetupInfo              *config.Result
	Options                []Option
}

SetupSpec configures RunSetupServer.

type UpSpec

type UpSpec struct {
	Reader                 io.Reader
	Writer                 io.WriteCloser
	AllowGitCredentials    bool
	AllowDockerCredentials bool
	Workspace              *provider2.Workspace
	Options                []Option
}

UpSpec configures RunUpServer.

Jump to

Keyboard shortcuts

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