source

package
v2.0.0-alpha-2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LastModified = "Last-Modified"
	ETag         = "ETag"
)

Variables

This section is empty.

Functions

func Download

func Download(ctx context.Context, url string, header RequestHeader) (io.ReadCloser, error)

func GetContentLength

func GetContentLength(ctx context.Context, url string, header RequestHeader) (int64, error)

func GetLastModifiedMillis

func GetLastModifiedMillis(ctx context.Context, url string, header RequestHeader) (int64, error)

func IsExpired

func IsExpired(ctx context.Context, url string, header RequestHeader, expireInfo map[string]string) (bool, error)

func IsSupportRange

func IsSupportRange(ctx context.Context, url string, header RequestHeader) (bool, error)

func Register

func Register(schema string, resourceClient ResourceClient)

func UnRegister

func UnRegister(schema string)

Types

type ClientManager

type ClientManager interface {
	ResourceClient
	Register(schema string, resourceClient ResourceClient)
	UnRegister(schema string)
}

func NewManager

func NewManager() ClientManager

type RequestHeader

type RequestHeader map[string]string

RequestHeader request header

func (RequestHeader) Get

func (h RequestHeader) Get(key string) string

type ResourceClient

type ResourceClient interface {

	// GetContentLength get length of resource content
	// return -l if request fail
	// return task.IllegalSourceFileLen if response status is not StatusOK and StatusPartialContent
	GetContentLength(ctx context.Context, url string, header RequestHeader, rang *rangers.Range) (int64, error)

	// IsSupportRange checks if resource supports breakpoint continuation
	IsSupportRange(ctx context.Context, url string, header RequestHeader) (bool, error)

	// IsExpired checks if a resource received or stored is the same.
	IsExpired(ctx context.Context, url string, header RequestHeader, expireInfo map[string]string) (bool, error)

	// Download downloads from source
	Download(ctx context.Context, url string, header RequestHeader, rang *rangers.Range) (io.ReadCloser, error)

	// DownloadWithResponseHeader download from source with responseHeader
	DownloadWithResponseHeader(ctx context.Context, url string, header RequestHeader, rang *rangers.Range) (io.ReadCloser, ResponseHeader, error)

	// GetLastModifiedMillis gets last modified timestamp milliseconds of resource
	GetLastModifiedMillis(ctx context.Context, url string, header RequestHeader) (int64, error)
}

ResourceClient supply apis that interact with the source.

func LoadPlugin

func LoadPlugin(schema string) (ResourceClient, error)

type ResponseHeader

type ResponseHeader map[string]string

ResponseHeader response header

func DownloadWithResponseHeader

func DownloadWithResponseHeader(ctx context.Context, url string, header RequestHeader) (io.ReadCloser, ResponseHeader, error)

func (ResponseHeader) Get

func (h ResponseHeader) Get(key string) string

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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