segmented

package
v0.0.0-...-6c4fd92 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: NIST-PD-fallback Imports: 14 Imported by: 1

Documentation

Overview

Package segmented publishes and retrieves segmented objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(ctx context.Context, source io.ReaderAt, opts ServeOptions) (endpoint.Producer, error)

Serve publishes a segmented object.

Types

type FetchOptions

type FetchOptions struct {
	SegmentRange

	// Fw specifies the L3 Forwarder.
	// Default is the default Forwarder.
	Fw l3.Forwarder `json:"-"`

	// RetxLimit is the maximum number of retransmissions, excluding initial Interest.
	// Default is no retransmission.
	RetxLimit int `json:"retxLimit,omitempty"`

	// MaxCwnd is the maximum effective congestion window.
	// Default is no limitation.
	MaxCwnd int `json:"maxCwnd,omitempty"`

	// Verifier is a public key to verify Data.
	// Default is NopVerifier.
	Verifier ndn.Verifier `json:"-"`
}

FetchOptions contains options for Fetch function.

type FetchResult

type FetchResult interface {
	// Unordered emits Data packets as they arrive, not sorted in segment number order.
	Unordered(ctx context.Context, unordered chan<- *ndn.Data) error
	// Ordered emits Data packets in segment number order.
	Ordered(ctx context.Context, ordered chan<- *ndn.Data) error
	// Chunks emits Data packet payload in segment number order.
	Chunks(ctx context.Context, chunks chan<- []byte) error
	// Pipe writes the payload to the Writer.
	Pipe(ctx context.Context, w io.Writer) error
	// Packet returns a slice of Data packets.
	Packets(ctx context.Context) ([]*ndn.Data, error)
	// Payload returns reassembled payload.
	Payload(ctx context.Context) ([]byte, error)

	// Count returns the number of segments retrieved so far.
	Count() int
	// EstimatedTotal returns the estimated number of total segments.
	// Returns -1 if unknown.
	EstimatedTotal() int
}

FetchResult contains result of Fetch function.

Fetching is lazy, and it starts when an output format is accessed. You may only access one output format on this instance, and it can be accessed only once.

func Fetch

func Fetch(name ndn.Name, opts FetchOptions) FetchResult

Fetch retrieves a segmented object.

type SegmentRange

type SegmentRange struct {
	// SegmentBegin is the first segment number.
	// Default is zero.
	SegmentBegin uint64 `json:"segmentBegin,omitempty"`

	// SegmentEnd is the last segment number plus one.
	// Default is math.MaxUint64.
	//
	// Data FinalBlock field is always respected.
	SegmentEnd uint64 `json:"segmentEnd,omitempty"`
}

SegmentRange specifies range of segment numbers.

func (*SegmentRange) SegmentRangeApplyDefaults

func (opts *SegmentRange) SegmentRangeApplyDefaults()

SegmentRangeApplyDefaults applies defaults in SegmentRange struct.

type ServeOptions

type ServeOptions struct {
	// ProducerOptions includes prefix, L3 forwarder, signer, etc.
	// Handler will be overwritten.
	endpoint.ProducerOptions

	// ContentType is Data packet ContentType.
	// Default is an.ContentBlob.
	ContentType ndn.ContentType

	// Freshness is Data packet FreshnessPeriod.
	// Default is zero.
	Freshness time.Duration

	// ChunkSize is Data payload length.
	// Default is 4096.
	ChunkSize int
}

ServeOptions contains options for Serve function.

Jump to

Keyboard shortcuts

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