stream

package
v0.0.0-...-1b9e8c6 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultStreamIdleTimeout is the timeout for idle stream.
	DefaultStreamIdleTimeout = 4 * time.Hour

	// DefaultStreamCreationTimeout is the timeout for stream creation.
	DefaultStreamCreationTimeout = 30 * time.Second
)

Keep these constants consistent with the peers in official package: k8s.io/kubernetes/pkg/kubelet/server.

Variables

View Source
var (
	// CacheTTL is timeout after which tokens become invalid.
	CacheTTL = 1 * time.Minute
	// MaxInFlight is the maximum number of in-flight requests to allow.
	MaxInFlight = 1000
	// TokenLen is the length of the random base64 encoded token identifying the request.
	TokenLen = 8
)
View Source
var DefaultConfig = Config{
	StreamIdleTimeout:               4 * time.Hour,
	StreamCreationTimeout:           DefaultStreamCreationTimeout,
	SupportedRemoteCommandProtocols: SupportedStreamingProtocols,
	SupportedPortForwardProtocols:   SupportedPortForwardProtocols,
}

DefaultConfig provides default values for server Config.

View Source
var SupportedPortForwardProtocols = []string{constant.PortForwardProtocolV1Name}

SupportedPortForwardProtocols is the portforward protocols which server supports.

SupportedStreamingProtocols is the streaming protocols which server supports.

Functions

func ErrorStreamingDisabled

func ErrorStreamingDisabled(method string) error

ErrorStreamingDisabled returns error when the streaming method is disabled.

func ErrorTooManyInFlight

func ErrorTooManyInFlight() error

ErrorTooManyInFlight returns error when the maximum number of in-flight requests is exceeded.

func WriteError

func WriteError(err error, w http.ResponseWriter) error

WriteError translates a CRI streaming error into an appropriate HTTP response.

Types

type Config

type Config struct {
	// Address is the addr:port address the server will listen on.
	Address string

	// BaseURL is the optional base URL for constructing streaming URLs. If empty, the baseURL will be constructed from the serve address.
	BaseURL *url.URL

	// StreamIdleTimeout is how long to leave idle connections open for.
	StreamIdleTimeout time.Duration
	// StreamCreationTimeout is how long to wait for clients to create streams. Only used for SPDY streaming.
	StreamCreationTimeout time.Duration

	// SupportedStreamingProtocols is the streaming protocols which server supports.
	SupportedRemoteCommandProtocols []string
	// SupportedPortForwardProtocol is the portforward protocols which server supports.
	SupportedPortForwardProtocols []string
}

Config defines the options used for running the stream server.

type Runtime

type Runtime interface {
	// Exec executes the command in pod.
	Exec(containerID string, cmd []string, streamOpts *remotecommand.Options, streams *remotecommand.Streams) error

	// Attach attaches to pod.
	Attach(containerID string, streamOpts *remotecommand.Options, streams *remotecommand.Streams) error

	// PortForward forward port to pod.
	PortForward(name string, port int32, stream io.ReadWriteCloser) error
}

Runtime is the interface to execute the commands and provide the streams.

type Server

type Server interface {
	// GetExec get the serving URL for Exec request.
	GetExec(*runtimeapi.ExecRequest) (*runtimeapi.ExecResponse, error)

	// GetAttach get the serving URL for Attach request.
	GetAttach(*runtimeapi.AttachRequest) (*runtimeapi.AttachResponse, error)

	// GetPortForward get the serving URL for PortForward request.
	GetPortForward(*runtimeapi.PortForwardRequest) (*runtimeapi.PortForwardResponse, error)

	// Start starts the stream server.
	Start() error
}

Server as an interface defines all operations against stream server.

func NewServer

func NewServer(config Config, runtime Runtime) (Server, error)

NewServer creates a new stream server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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