Documentation
¶
Index ¶
- Constants
- Variables
- func NewLargeFile(ctx context.Context, name string, opts ...LargeFileOption) (largefile.Reader, error)
- type Downloader
- type FS
- func (fs *FS) Base(p string) string
- func (fs *FS) IsNotExist(err error) bool
- func (fs *FS) IsPermissionError(err error) bool
- func (fs *FS) Join(components ...string) string
- func (fs *FS) Lstat(_ context.Context, _ string) (file.Info, error)
- func (fs *FS) Open(name string) (fs.File, error)
- func (fs *FS) OpenCtx(ctx context.Context, name string) (fs.File, error)
- func (fs *FS) Readlink(_ context.Context, _ string) (string, error)
- func (fs *FS) Scheme() string
- func (fs *FS) Stat(_ context.Context, _ string) (file.Info, error)
- func (fs *FS) SysXAttr(existing any, merge file.XAttr) any
- func (fs *FS) XAttr(_ context.Context, _ string, info file.Info) (file.XAttr, error)
- type LargeFile
- type LargeFileOption
- func WithDefaultRetryDelay(delay time.Duration) LargeFileOption
- func WithLargeFileBlockSize(blockSize int) LargeFileOption
- func WithLargeFileDigest(dig digests.Hash) LargeFileOption
- func WithLargeFileLogger(slog *slog.Logger) LargeFileOption
- func WithLargeFileTransport(transport *http.Transport) LargeFileOption
- type Option
- type Response
Constants ¶
const DefaultLargeFileBlockSize = 1024 * 16 // Default block size is 16 KiB.
Variables ¶
var ErrNoRangeSupport = &errNoRangeSupport{}
Functions ¶
func NewLargeFile ¶
func NewLargeFile(ctx context.Context, name string, opts ...LargeFileOption) (largefile.Reader, error)
OpenLargeFile opens a large file for concurrent reading using file.largefile.Reader.
Types ¶
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader facilitates downloading files using largefile with configurable options.
func NewDownloader ¶
func NewDownloader() *Downloader
NewDownloader creates a new Downloader instance.
func (*Downloader) DownloadFile ¶
DownloadFile downloads the file from the specified URL to the destination path using a temporary file for the download process that is renamed to the destination path on successful completion. The partial download file has a suffix of ".partialdownload".
func (*Downloader) WithDownloaderOptions ¶
func (d *Downloader) WithDownloaderOptions(opts ...largefile.DownloadOption) *Downloader
WithDownloaderOptions appends the specified largefile.DownloadOptions to the Downloader.
func (*Downloader) WithReaderOptions ¶
func (d *Downloader) WithReaderOptions(opts ...LargeFileOption) *Downloader
WithReaderOptions appends the specified LargeFileOptions to the Downloader.
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
func (*FS) IsNotExist ¶
func (*FS) IsPermissionError ¶
type LargeFile ¶
type LargeFile struct {
// contains filtered or unexported fields
}
LargeFile implements largefile.Reader for large files accessed via HTTP. Such files must support range requests, and the "Accept-Ranges" header must be set to "bytes". If the server does not support range requests, it returns ErrNoRangeSupport. A HEAD request is made to the file to determine its content length and digest (if available). The file must be capable of being read concurrently in blocks of a specified range. Partial reads are treated as errors.
func (*LargeFile) ContentLengthAndBlockSize ¶
type LargeFileOption ¶
type LargeFileOption func(o *largeFileOptions)
func WithDefaultRetryDelay ¶
func WithDefaultRetryDelay(delay time.Duration) LargeFileOption
WithDefaultRetryDelay sets the default retry delay for HTTP requests. This is used when the server responds with a 503 Service Unavailable status but does not provide a Retry-After header or that header cannot be parsed. The default value is 1 minute.
func WithLargeFileBlockSize ¶
func WithLargeFileBlockSize(blockSize int) LargeFileOption
WithLargeFileBlockSize sets the block size for reading large files.
func WithLargeFileDigest ¶
func WithLargeFileDigest(dig digests.Hash) LargeFileOption
WithLargeFileDigest sets the digest for the large file.
func WithLargeFileLogger ¶
func WithLargeFileLogger(slog *slog.Logger) LargeFileOption
WithLargeFileLogger sets the logger. If not set, a discard logger is used.
func WithLargeFileTransport ¶
func WithLargeFileTransport(transport *http.Transport) LargeFileOption
WithLargeFileTransport sets the HTTP transport for making requests, if not set a simple default is used.
type Response ¶
type Response struct {
// When the response was received.
When time.Time
// Fields copied from the http.Response.
Headers http.Header
Trailers http.Header
ContentLength int64
StatusCode int
ProtoMajor, ProtoMinir int
TransferEncoding []string
}
Response is a redacted version of http.Response that can be marshaled using gob.