Documentation ¶
Index ¶
- Variables
- type File
- func (f *File) Close() error
- func (f *File) GetHeader() http.Header
- func (f *File) GetRequestURL() *url.URL
- func (f *File) NumConns() int
- func (f *File) Read(buf []byte) (int, error)
- func (f *File) ReadAt(buf []byte, offset int64) (int, error)
- func (f *File) Reset() error
- func (f *File) Seek(offset int64, whence int) (int64, error)
- func (f *File) Stat() (os.FileInfo, error)
- type FileInfo
- type GetURLFunc
- type LogFunc
- type NeedsRenewalFunc
- type Resetter
- type ServerError
- type ServerErrorCode
- type Settings
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = goerrors.New("HTTP file not found on server")
ErrNotFound is returned when the HTTP server returns 404 - it's not considered a temporary error
var ErrTooManyRenewals = goerrors.New("Giving up, getting too many renewals. Try again later or contact support.")
ErrTooManyRenewals is returned when we keep calling the GetURLFunc but it immediately return an errors marked as renewal-related by NeedsRenewalFunc. This can happen when servers are misconfigured.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { Log LogFunc LogLevel int ConnStaleThreshold time.Duration MaxConns int ForbidBacktracking bool DumpStats bool // contains filtered or unexported fields }
File allows accessing a file served by an HTTP server as if it was local (for random-access reading purposes, not writing)
func Open ¶
func Open(getURL GetURLFunc, needsRenewal NeedsRenewalFunc, settings *Settings) (*File, error)
Open returns a new htfs.File. Note that it differs from os.Open in that it does a first request to determine the remote file's size. If that fails (after retries), an error will be returned.
func (*File) GetHeader ¶
GetHeader returns the header the server responded with on our initial request. It may contain checksums which could be used for integrity checking.
func (*File) GetRequestURL ¶
GetRequestURL returns the first good URL File made a request to.
func (*File) NumConns ¶
NumConns returns the number of connections currently used by the File to serve ReadAt calls
func (*File) ReadAt ¶
ReadAt reads len(buf) byte from the remote file at offset. It returns the number of bytes read, and an error. In case of temporary network errors or timeouts, it will retry with truncated exponential backoff according to RetrySettings
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
FileInfo implements os.FileInfo for Files
type GetURLFunc ¶
A GetURLFunc returns a URL we can download the resource from. It's handy to have this as a function rather than a constant for signed expiring URLs
type NeedsRenewalFunc ¶
A NeedsRenewalFunc analyzes an HTTP response and returns true if it needs to be renewed
type ServerError ¶
type ServerError struct { Host string Message string Code ServerErrorCode StatusCode int }
ServerError represents an error htfs has encountered when talking to a remote server.
func (*ServerError) Error ¶
func (se *ServerError) Error() string
type ServerErrorCode ¶
type ServerErrorCode int64
ServerErrorCode represents an error condition where some server does not support htfs - perhaps because it has no range support, or because it returned a bad HTTP status code.
const ( // ServerErrorCodeUnknown does not map to any known errors. // It's used for any unexpected HTTP status codes. ServerErrorCodeUnknown ServerErrorCode = iota // ServerErrorCodeNoRangeSupport indicates that the remote // server does not support HTTP Range Requests: // https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests ServerErrorCodeNoRangeSupport )