alioss

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LockIdle unlock
	LockIdle lockType = 0b0000
	// LockReader reader lock type
	LockReader lockType = 0b0001
	// LockWriter writer lock type
	LockWriter lockType = 0b0010
	// LockRWriter reader and writer lock type
	LockRWriter lockType = LockReader | LockWriter
)
View Source
const (
	// ObjectLockFile lock file path
	ObjectLockFile = ".git-syncer/lockfile"

	// ObjectHeadLinkFile head log file path
	ObjectHeadLinkFile = ".git-syncer/head"

	// ObjectLogDir log dir path
	ObjectLogDir = ".git-syncer/logs"
)
View Source
const JSONTimeLayout = time.RFC3339

JSONTimeLayout time format

View Source
const LockMaxAge = time.Minute * 5

LockMaxAge lock max age

Variables

This section is empty.

Functions

func AsOssError

func AsOssError(err error) *oss.ServiceError

AsOssError try to convert to oss service error

func IsObjectNotFoundErr

func IsObjectNotFoundErr(err error) bool

IsObjectNotFoundErr object not found err

Types

type Alioss

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

Alioss alioss contrib

func New

func New(opt Options, bkt Bucket) (*Alioss, error)

New create alioss contrib

func (*Alioss) GetHeadSHA1

func (a *Alioss) GetHeadSHA1() (string, error)

GetHeadSHA1 get head sha1 from alioss contrib

func (*Alioss) PathToKey

func (a *Alioss) PathToKey(path string) string

PathToKey return path with `base` prefix

func (*Alioss) PeekLog

func (a *Alioss) PeekLog() (*LogInfo, error)

PeekLog get head log

func (*Alioss) PushLog

func (a *Alioss) PushLog(info LogInfo) error

PushLog log to contrib

func (*Alioss) Sync

func (a *Alioss) Sync(sha1 string, uploads []string, deletes []string) (uploaded []string, deleted []string, err error)

Sync sync files to alioss contrib

type Bucket

type Bucket interface {
	GetObject(key string, options ...oss.Option) (io.ReadCloser, error)
	PutObject(key string, reader io.Reader, options ...oss.Option) error
	DeleteObject(key string, options ...oss.Option) error
	IsObjectExist(key string, options ...oss.Option) (bool, error)
	PutSymlink(symObjectKey string, targetObjectKey string, options ...oss.Option) error
}

Bucket bucket interface to interact with alioss

type JSONTime

type JSONTime struct {
	time.Time
}

JSONTime jsonable of time.Time

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

MarshalJSON stringify from time.Time

func (*JSONTime) UnmarshalJSON

func (t *JSONTime) UnmarshalJSON(bs []byte) error

UnmarshalJSON parse to time.Time

type LockInfo

type LockInfo struct {
	Mutex      lockType `json:"Mutex"`
	Date       JSONTime `json:"Date"`
	ExpireDate JSONTime `json:"ExpireDate"`
	LockID     string   `json:"LockID"`
}

LockInfo lock info

type LogInfo

type LogInfo struct {
	SHA1     string         `json:"SHA1"`
	RefSHA1  string         `json:"RefSHA1"`
	Date     JSONTime       `json:"Date"`
	Uploaded []UploadedFile `json:"Uploaded"`
	Deleted  []string       `json:"Deleted"`
}

LogInfo log info

type Options

type Options interface {
	Endpoint() string
	AccessKeyID() string
	AccessKeySecret() string
	Bucket() string
	Base() string
}

Options alioss Options

type UploadedFile

type UploadedFile struct {
	Path string `json:"Path"`
	Size int64  `json:"Size"`
	SHA1 string `json:"SHA1"`
}

UploadedFile uploaded file to log

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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