package client

import "sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client"

Index

Constants

const CloseTimeout = 10 * time.Second

CloseTimeout is the timeout to wait CLOSE_RSP packet after a successful delivery of CLOSE_REQ.

Types

type DialFailureReason

type DialFailureReason string
const (
	DialFailureUnknown DialFailureReason = "unknown"
	// DialFailureTimeout indicates the hard 30 second timeout was hit.
	DialFailureTimeout DialFailureReason = "timeout"
	// DialFailureContext indicates that the context was cancelled or reached it's deadline before
	// the dial response was returned.
	DialFailureContext DialFailureReason = "context"
	// DialFailureEndpoint indicates that the konnectivity-agent was unable to reach the backend endpoint.
	DialFailureEndpoint DialFailureReason = "endpoint"
	// DialFailureDialClosed indicates that the client received a CloseDial response, indicating the
	// connection was closed before the dial could complete.
	DialFailureDialClosed DialFailureReason = "dialclosed"
	// DialFailureTunnelClosed indicates that the client connection was closed before the dial could
	// complete.
	DialFailureTunnelClosed DialFailureReason = "tunnelclosed"
)

func GetDialFailureReason

func GetDialFailureReason(err error) (isDialFailure bool, reason DialFailureReason)

type Tunnel

type Tunnel interface {
	// Dial connects to the address on the named network, similar to
	// what net.Dial does. The only supported protocol is tcp.
	DialContext(requestCtx context.Context, protocol, address string) (net.Conn, error)
	// Done returns a channel that is closed when the tunnel is no longer serving any connections,
	// and can no longer be used.
	Done() <-chan struct{}
}

Tunnel provides ability to dial a connection through a tunnel.

func CreateSingleUseGrpcTunnel

func CreateSingleUseGrpcTunnel(tunnelCtx context.Context, address string, opts ...grpc.DialOption) (Tunnel, error)

CreateSingleUseGrpcTunnel creates a Tunnel to dial to a remote server through a gRPC based proxy service. Currently, a single tunnel supports a single connection, and the tunnel is closed when the connection is terminated The Dial() method of the returned tunnel should only be called once Deprecated 2022-06-07: use CreateSingleUseGrpcTunnelWithContext

func CreateSingleUseGrpcTunnelWithContext

func CreateSingleUseGrpcTunnelWithContext(createCtx, tunnelCtx context.Context, address string, opts ...grpc.DialOption) (Tunnel, error)

CreateSingleUseGrpcTunnelWithContext creates a Tunnel to dial to a remote server through a gRPC based proxy service. Currently, a single tunnel supports a single connection. The tunnel is normally closed when the connection is terminated. If createCtx is cancelled before tunnel creation, an error will be returned. If tunnelCtx is cancelled while the tunnel is still in use, the tunnel (and any in flight connections) will be closed. The Dial() method of the returned tunnel should only be called once

Source Files

client.go conn.go

Version
v0.0.33
Published
Sep 21, 2022
Platform
js/wasm
Imports
12 packages
Last checked
1 hour ago

Tools for package owners.