podforward

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const PortUnspecified uint16 = 0

PortUnspecified is the fallback value of the port. THe forwarder generates a random port if this value is used.

Variables

View Source
var ErrEmptyPodsListed = errors.New("empty pods listed")

Functions

This section is empty.

Types

type ForwardHandle

type ForwardHandle interface {
	// LocalPort returns the local port of the forwarder by remote port.
	LocalPort(remortPort uint16) uint16

	// StopForward stops the forwarder.
	// It is safe to call this method multiple times.
	StopForward()

	// ErrChann returns the error channel of the forwarder.
	// It will be closed when the forwarder is stopped.
	ErrChan() <-chan error
}

ForwardHandle controls access to a pod forwarder.

func Forward

func Forward(
	forwardCtx context.Context,
	restConfig *rest.Config,
	namespace string,
	options ...Option,
) (ForwardHandle, error)

Forward forwards request to pod.

func ForwardWithReconnect

func ForwardWithReconnect(
	logger logger.Logger,
	forwardTimeout time.Duration,
	backoffTicker <-chan time.Time,
	restConfig *rest.Config,
	namespace string,
	options ...Option,
) (ForwardHandle, error)

ForwardWithReconnect creates pod forwarder with automatic reconnection support. It bails if fails to create first connection. Errors after first connection will trigger forwarder reconnection. No error will be returned from the returned forward handle until stopped.

type Forwarder

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

type FromRemotePortOption

type FromRemotePortOption interface {
	FromRemotePort(remotePort uint16) Option
}

func ToLocalPort

func ToLocalPort(localPort uint16) FromRemotePortOption

ToLocalPort creates a new option to specify the local port.

type Option

type Option func(forwarder *Forwarder) error

Option specifies options for configuring the podstream reader.

func FromSelectedPods

func FromSelectedPods(labelSelector string) Option

FromSelectedPods sets the label selector.

func FromService

func FromService(serviceName string) Option

FromService sets the label selector by service name. It expects the service exists before the forwarder is created.

func WithLogger

func WithLogger(logger kubekit.Logger) Option

WithLogger sets the logger to be used by the streamer.

type ToLocalPortOption

type ToLocalPortOption interface {
	ToLocalPort(localPort uint16) Option
}

func FromRemotePort

func FromRemotePort(remotePort uint16) ToLocalPortOption

FromRemotePort creates a new option to specify the remote port.

Jump to

Keyboard shortcuts

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