sdk

package
v0.0.0-...-9834278 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 25 Imported by: 1

Documentation

Index

Constants

View Source
const (
	UPLOAD_DATA = 1 << iota
	CRC32_MD5
	HDR_CRC32
)
View Source
const (
	PKG_ALIGN = 4096
	PKG_SIZE  = 4194304
	HDR_SIZE  = 102400
)
View Source
const (
	OFF  = iota // OFF
	FULL        // 整个文件读取
	FAST        // 头部检查成功再整个文件读取
)

秒传级别设置 对应 Config.RefLevel

View Source
const (
	COVER  = iota // 合并或覆盖
	RENAME        // 重命名
	THROW         // 报错
	SKIP          // 跳过
)

同名冲突解决方式

View Source
const PathSeparator = "/"

Variables

View Source
var (
	// ErrFull chan full.
	ErrFull    = errors.New("fanout: chan full")
	ErrTimeout = errors.New("fanout: chan full, wait timeout")
)

Functions

func NewDataReader

func NewDataReader(c core.Ctx, h core.Handler, bktID int64, d *core.DataInfo, endecKey string) *dataReader

Types

type Config

type Config struct {
	UserName string // 用户名
	Password string // 密码
	DataSync bool   // 断电保护策略(Power-off Protection Policy),强制每次写入数据后刷到磁盘
	RefLevel uint32 // 秒传级别设置:OFF(默认) / FULL: Ref / FAST: TryRef+Ref
	PkgThres uint32 // 打包个数限制,不设置默认1000个
	WiseCmpr uint32 // 智能压缩,根据文件类型决定是否压缩,取值见core.DATA_CMPR_MASK
	CmprQlty uint32 // 压缩级别,br:[0,11],gzip:[-3,9],zstd:[0,10]
	EndecWay uint32 // 加密方式,取值见core.DATA_ENDEC_MASK
	EndecKey string // 加密KEY,SM4需要固定为16个字符,AES256需要大于16个字符
	DontSync string // 不同步的文件名通配符(https://pkg.go.dev/path/filepath#Match),用分号分隔
	Conflict uint32 // 同名冲突解决方式,COVER:合并或覆盖 / RENAME:重命名 / THROW:报错 / SKIP:跳过
	NameTmpl string // 重命名尾巴,"%s的副本"
	WorkersN uint32 // 并发池大小,不小于16

}

type DummyArchiver

type DummyArchiver struct{}

func (DummyArchiver) CheckExt

func (DummyArchiver) CheckExt(string) error

func (DummyArchiver) Compress

func (DummyArchiver) Compress(in io.Reader, out io.Writer) error

func (DummyArchiver) Decompress

func (DummyArchiver) Decompress(in io.Reader, out io.Writer) error

type Fanout

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

Fanout async consume data from chan.

func NewFanout

func NewFanout(opts ...Option) *Fanout

NewFanout new a fanout struct.

func (*Fanout) Close

func (c *Fanout) Close() error

Close close fanout.

func (*Fanout) Do

func (c *Fanout) Do(ctx core.Ctx, f func(ctx core.Ctx)) (err error)

Do save a callback func.

func (*Fanout) DoRetry

func (c *Fanout) DoRetry(ctx core.Ctx, f func(ctx core.Ctx) error, maxRetry int) (err error)

DoRetry Auto retry call func with back off, if return err Notice: no retry if panic

func (*Fanout) DoWait

func (c *Fanout) DoWait(ctx core.Ctx, f func(ctx core.Ctx), timeout time.Duration) (err error)

Do save a callback func, wait for timeout if the channel is full.

func (*Fanout) DoWhen

func (c *Fanout) DoWhen(ctx core.Ctx, f func(ctx core.Ctx), cond bool) (err error)

func (*Fanout) MustDo

func (c *Fanout) MustDo(ctx core.Ctx, f func(ctx core.Ctx)) (err error)

MustDo save a callback func.

func (*Fanout) Shutdown

func (c *Fanout) Shutdown(timeout time.Duration)

Shutdown wait fanout with given timeout.

func (*Fanout) TunePool

func (c *Fanout) TunePool(n int)

TunePool Dynamically adjust the gorutine pool size

func (*Fanout) TuneWorker

func (c *Fanout) TuneWorker(n int)

TuneWorker Dynamically adjust the worker number

func (*Fanout) Wait

func (c *Fanout) Wait() error

Wait wait fanout.

type Option

type Option func(*options)

Option fanout option

func Buffer

func Buffer(n int) Option

Buffer specifies the buffer of fanout

func Worker

func Worker(n int) Option

Worker specifies the worker of fanout

type OrcasSDK

type OrcasSDK interface {
	H() core.Handler

	Close()

	Login(cfg Config) (core.Ctx, *core.UserInfo, []*core.BucketInfo, error)

	Path2ID(c core.Ctx, bktID, pid int64, rpath string) (id int64, err error)
	ID2Path(c core.Ctx, bktID, id int64) (rpath string, err error)

	Upload(c core.Ctx, bktID, pid int64, lpath string) error
	Download(c core.Ctx, bktID, pid int64, lpath string) error
}

func New

func New(h core.Handler) OrcasSDK

type OrcasSDKImpl

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

func (*OrcasSDKImpl) Close

func (osi *OrcasSDKImpl) Close()

func (*OrcasSDKImpl) Download

func (osi *OrcasSDKImpl) Download(c core.Ctx, bktID, id int64, lpath string) error

func (*OrcasSDKImpl) H

func (osi *OrcasSDKImpl) H() core.Handler

func (*OrcasSDKImpl) ID2Path

func (osi *OrcasSDKImpl) ID2Path(c core.Ctx, bktID, id int64) (rpath string, err error)

func (*OrcasSDKImpl) Login

func (osi *OrcasSDKImpl) Login(cfg Config) (core.Ctx, *core.UserInfo, []*core.BucketInfo, error)

func (*OrcasSDKImpl) Path2ID

func (osi *OrcasSDKImpl) Path2ID(c core.Ctx, bktID, pid int64, rpath string) (int64, error)

func (*OrcasSDKImpl) Upload

func (osi *OrcasSDKImpl) Upload(c core.Ctx, bktID, pid int64, lpath string) error

Jump to

Keyboard shortcuts

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