download

package
v1.0.89 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package download provides validated full and ranged streams.

Index

Constants

View Source
const (
	// DefaultPartSize keeps a 100 MiB object near 13 requests while capping replay at 8 MiB.
	DefaultPartSize = int64(8 * 1024 * 1024)
	// DefaultPartRetries tolerates three transient failures without prolonged retrying.
	DefaultPartRetries = 3
	// DefaultRetryDelay keeps three local backoffs below one second before jitter.
	DefaultRetryDelay = 100 * time.Millisecond
	// DefaultRetryWaitBudget caps cumulative local sleep for interactive callers.
	DefaultRetryWaitBudget = 3 * time.Second
	// DefaultIdleTimeout detects a dead connection within a minute without limiting slow progress.
	DefaultIdleTimeout = 60 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIStreamFunc

type APIStreamFunc func(context.Context, *larkcore.ApiReq, ...client.Option) (*http.Response, error)

APIStreamFunc is the OAPI streaming capability used by Transport.

type ByteRange

type ByteRange struct {
	Start int64
	End   int64
}

ByteRange is an inclusive HTTP byte range.

func (ByteRange) HeaderValue

func (r ByteRange) HeaderValue() string

HeaderValue returns the value for an HTTP Range header.

type OAPI

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

OAPI builds authenticated download transports.

func NewOAPI

func NewOAPI(doStream APIStreamFunc) OAPI

NewOAPI creates an authenticated transport factory.

func (OAPI) Get

func (o OAPI) Get(path string, options ...OAPIRequestOption) Transport

Get creates fresh SDK request state for every fetch.

type OAPIRequestOption

type OAPIRequestOption func(*oapiRequestSpec)

OAPIRequestOption configures one declarative OAPI endpoint.

func PathParam

func PathParam(name, value string) OAPIRequestOption

PathParam binds one SDK path placeholder.

func Query

func Query(name, value string) OAPIRequestOption

Query binds one OAPI query parameter.

func QueryIf

func QueryIf(name, value string) OAPIRequestOption

QueryIf binds a query parameter when value is non-empty.

type Options

type Options struct {
	PartSize     int64
	MaxResponses int
	// MaxPartRetries bounds retries per range. Zero selects the default.
	MaxPartRetries int
	// RetryDelay is the base exponential backoff. Zero selects the default.
	RetryDelay time.Duration
	// RetryWaitBudget bounds cumulative retry sleeps. Zero selects the default.
	RetryWaitBudget time.Duration
	// IdleTimeout bounds waiting for response headers or one body read. Time
	// between caller reads does not count. Zero selects the default.
	IdleTimeout time.Duration
	// DisableMultipart forces one full response.
	DisableMultipart bool
}

Options controls multipart behavior. Zero values select production defaults.

type Request

type Request struct {
	Range   *ByteRange
	IfRange string
}

Request describes one full or ranged fetch.

func (Request) Headers

func (r Request) Headers() http.Header

Headers keeps byte offsets tied to the transferred representation.

type Source

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

Source binds a transport to its representation stability.

func ImmutableSource

func ImmutableSource(transport Transport) Source

ImmutableSource allows multipart reads without a validator.

func MutableSource

func MutableSource(transport Transport) Source

MutableSource requires a strong ETag before combining responses.

type Stream

type Stream struct {
	Body          io.ReadCloser
	Header        http.Header
	ContentLength int64
}

Stream is one logical full or multipart response.

func Open

func Open(ctx context.Context, source Source, opts Options) (*Stream, error)

Open probes range support and returns one validated stream.

type Transport

type Transport func(context.Context, Request) (*http.Response, error)

Transport performs one replay-safe fetch and binds ctx to the response body. Non-successful HTTP responses must be returned as typed errors with retryability decided at this boundary.

func URL

func URL(httpClient *http.Client, rawURL string) Transport

URL adapts a caller-validated URL and HTTP client to Transport. The caller owns source and redirect validation; Open owns transfer timeouts.

Jump to

Keyboard shortcuts

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