io

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2016 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InvalidCtx = 701 // UP: 无效的上下文(bput),可能情况:Ctx非法或者已经被淘汰(太久未使用)
)

Variables

View Source
var ErrInvalidPutProgress = errors.New("invalid put progress")
View Source
var ErrPutFailed = errors.New("resumable put failed")
View Source
var ErrUnmatchedChecksum = errors.New("unmatched checksum")

Functions

func BlockCount

func BlockCount(fsize int64) int

func Blockput

func Blockput(
	c rpc.Client, l rpc.Logger, ret *BlkputRet, body io.Reader, size int) error

func Mkblock

func Mkblock(
	c rpc.Client, l rpc.Logger, ret *BlkputRet, blockSize int, body io.Reader, size int) error

func Mkfile

func Mkfile(
	c rpc.Client, l rpc.Logger, ret interface{}, key string, hasKey bool, fsize int64, extra *PutExtra) (err error)

func NewClient

func NewClient(token string, bindRemoteIp string) rpc.Client

func NewClientEx

func NewClientEx(token string, transport http.RoundTripper, bindRemoteIp string) rpc.Client

func Put

func Put(c rpc.Client, l rpc.Logger, ret interface{}, key string, f io.ReaderAt, fsize int64, extra *PutExtra) error

func PutFile

func PutFile(c rpc.Client, l rpc.Logger, ret interface{}, key, localFile string, extra *PutExtra) (err error)

func PutFileWithoutKey

func PutFileWithoutKey(c rpc.Client, l rpc.Logger, ret interface{}, localFile string, extra *PutExtra) (err error)

func PutWithoutKey

func PutWithoutKey(c rpc.Client, l rpc.Logger, ret interface{}, f io.ReaderAt, fsize int64, extra *PutExtra) error

func ResumableBlockput

func ResumableBlockput(
	c rpc.Client, l rpc.Logger, ret *BlkputRet, f io.ReaderAt, blkIdx, blkSize int, extra *PutExtra) (err error)

func SetSettings

func SetSettings(v *Settings)

Types

type BlkputRet

type BlkputRet struct {
	Ctx       string `json:"ctx"`
	Checksum  string `json:"checksum"`
	Crc32     uint32 `json:"crc32"`
	Offset    uint32 `json:"offset"`
	Host      string `json:"host"`
	ExpiredAt int64  `json:"expired_at"`
}

type ProgressRecord added in v1.6.2

type ProgressRecord struct {
	Progresses []BlkputRet `json:"progresses"`
}

type PutExtra

type PutExtra struct {
	Params       map[string]string                             // 可选。用户自定义参数,以"x:"开头 否则忽略
	MimeType     string                                        // 可选。
	ChunkSize    int                                           // 可选。每次上传的Chunk大小
	TryTimes     int                                           // 可选。尝试次数
	Progresses   []BlkputRet                                   // 可选。上传进度
	ProgressFile string                                        //可选。块级断点续传进度保存文件
	Notify       func(blkIdx int, blkSize int, ret *BlkputRet) // 可选。进度提示(注意多个block是并行传输的)
	NotifyErr    func(blkIdx int, blkSize int, err error)
}

@gist PutExtra

type PutRet

type PutRet struct {
	Hash string `json:"hash"` // 如果 uptoken 没有指定 ReturnBody,那么返回值是标准的 PutRet 结构
	Key  string `json:"key"`
}

type Settings

type Settings struct {
	TaskQsize int // 可选。任务队列大小。为 0 表示取 Workers * 4。
	Workers   int // 并行 Goroutine 数目。
	ChunkSize int // 默认的Chunk大小,不设定则为256k
	TryTimes  int // 默认的尝试次数,不设定则为3
}

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

func NewTransport

func NewTransport(token string, transport http.RoundTripper) *Transport

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error)

Jump to

Keyboard shortcuts

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