transfer

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package transfer provides client-side transfer types that marshal into the containerd transfer API protobuf messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerPath

type ContainerPath struct {
	ContainerID       string
	Path              string
	NoWalk            bool
	PreserveOwnership bool
}

ContainerPath represents a path within a running container's filesystem. It acts as either a source or destination in a transfer operation, identifying the container and path for archive operations.

func (*ContainerPath) MarshalAny

func (cp *ContainerPath) MarshalAny(ctx context.Context, sm streaming.StreamCreator) (typeurl.Any, error)

MarshalAny marshals the ContainerPath to a typeurl.Any.

type ReadStream

type ReadStream struct {
	MediaType string
	// contains filtered or unexported fields
}

ReadStream carries data from the client to the server (import direction). The client sends data through the stream and the server reads it.

After calling Transfer, callers must call Wait to block until the background send goroutine has completed and to obtain any error it encountered. Skipping Wait silently discards send errors and races the goroutine against caller teardown.

func NewReadStream

func NewReadStream(r io.Reader, mediaType string) *ReadStream

NewReadStream creates a ReadStream that will send data from r to the server during marshaling.

func (*ReadStream) MarshalAny

func (s *ReadStream) MarshalAny(ctx context.Context, sm streaming.StreamCreator) (typeurl.Any, error)

MarshalAny marshals the ReadStream, creating a streaming connection and starting a goroutine that sends data from the reader.

func (*ReadStream) Wait

func (s *ReadStream) Wait(ctx context.Context) error

Wait blocks until the background send goroutine has finished and returns any error it encountered. It must be called after the Transfer RPC returns. ctx is used only for cancellation; if it fires before the goroutine exits, Wait returns ctx.Err().

Note: SendStream does not currently return an error (errors are logged internally), so Wait primarily serves as a synchronization barrier to ensure the send goroutine has fully drained the reader before the caller proceeds.

type WriteStream

type WriteStream struct {
	MediaType string
	// contains filtered or unexported fields
}

WriteStream carries data from the server to the client (export direction). The server writes data into the stream and the client receives it.

After calling Transfer, callers must call Wait to block until the background receive goroutine has drained the stream into the underlying writer and to obtain any error it encountered. Skipping Wait races the goroutine against the caller reading the writer's buffer, and silently discards receive errors (producing an empty or truncated result indistinguishable from a successful empty response).

func NewWriteStream

func NewWriteStream(w io.Writer, mediaType string) *WriteStream

NewWriteStream creates a WriteStream that will receive data from the server into w during marshaling.

func (*WriteStream) MarshalAny

func (s *WriteStream) MarshalAny(ctx context.Context, sm streaming.StreamCreator) (typeurl.Any, error)

MarshalAny marshals the WriteStream, creating a streaming connection and starting a goroutine that receives data into the writer.

func (*WriteStream) Wait

func (s *WriteStream) Wait(ctx context.Context) error

Wait blocks until the background receive goroutine has finished draining the stream into the writer and returns any error it encountered. It must be called after the Transfer RPC returns. ctx is used only for cancellation; if it fires before the goroutine exits, Wait returns ctx.Err().

The Transfer RPC returning successfully only means the server has finished writing — the client-side io.Copy from the bidi stream into the writer runs in a separate goroutine that may still be in flight. Calling Wait ensures the writer's buffer is fully populated before the caller reads it, and surfaces any transport error rather than silently delivering an empty or truncated result.

Jump to

Keyboard shortcuts

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