source

package
v2.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: Apache-2.0 Imports: 10 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 ClientManagerImpl

type ClientManagerImpl struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*ClientManagerImpl) Download

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

func (*ClientManagerImpl) DownloadWithResponseHeader

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

func (*ClientManagerImpl) GetContentLength

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

func (*ClientManagerImpl) GetLastModifiedMillis

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

func (*ClientManagerImpl) IsExpired

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

func (*ClientManagerImpl) IsSupportRange

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

func (*ClientManagerImpl) Register

func (clientMgr *ClientManagerImpl) Register(schema string, resourceClient ResourceClient)

func (*ClientManagerImpl) UnRegister

func (clientMgr *ClientManagerImpl) UnRegister(schema string)

type RequestHeader

type RequestHeader map[string]string

request header

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) (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 download from source
	Download(ctx context.Context, url string, header RequestHeader) (io.ReadCloser, error)

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

	// GetLastModified get lastModified 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

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