Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnexpectedHTTPStatus = errors.New("unexpected http status")
Functions ¶
func EqualSplit ¶ added in v0.3.2
Types ¶
type BufferMode ¶
type BufferMode struct { Client *client.HTTPClient Options // contains filtered or unexported fields }
func GetBufferMode ¶ added in v0.2.1
func GetBufferMode(opts Options) *BufferMode
type ConsistentHashingMode ¶ added in v0.3.2
type ConsistentHashingMode struct { Client *client.HTTPClient Options // TODO: allow this to be configured and not just "BufferMode" FallbackStrategy Strategy // contains filtered or unexported fields }
func GetConsistentHashingMode ¶ added in v0.3.2
func GetConsistentHashingMode(opts Options) (*ConsistentHashingMode, error)
type Options ¶ added in v0.2.0
type Options struct { // Maximum number of chunks to download. If set to zero, GOMAXPROCS*4 // will be used. MaxConcurrency int // SliceSize is the number of bytes per slice in nginx. // See https://nginx.org/en/docs/http/ngx_http_slice_module.html SliceSize int64 // Minimum number of bytes per chunk. If set to zero, 16 MiB will be // used. MinChunkSize int64 Client client.Options // DomainsToCache is an allowlist of domains which may be routed via a // pull-through cache DomainsToCache []string // CacheHosts is a slice of hostnames to use as pull-through caches. // The ordering is significant and will be used with the consistent // hashing algorithm. The slice may contain empty entries which // correspond to a cache host which is currently unavailable. CacheHosts []string }
type Strategy ¶ added in v0.2.1
type Strategy interface { // Fetch retrieves the content from a given URL and returns it as an io.Reader along with the file size. // If an error occurs during the process, it returns nil for the reader, 0 for the fileSize, and the error itself. // This is the primary method that should be called to initiate a download of a file. Fetch(ctx context.Context, url string) (result io.Reader, fileSize int64, err error) // DoRequest sends an HTTP GET request with a specified range of bytes to the given URL using the provided context. // It returns the HTTP response and any error encountered during the request. It is intended that Fetch calls DoRequest // and that each chunk is downloaded with a call to DoRequest. DoRequest is exposed so that consistent-hashing can // utilize any strategy as a fall-back for chunk downloading. // // If the request fails to download or execute, an error is returned. // // The start and end parameters specify the byte range to request. // The trueURL parameter is the actual URL after any redirects. DoRequest(ctx context.Context, start, end int64, url string) (*http.Response, error) }
Click to show internal directories.
Click to hide internal directories.