operation

package
v0.0.0-...-9931aa1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// when the remote server does not allow range requests (Accept-Ranges was not set)
	ErrRangeRequestsNotSupported = errors.New("Range requests are not supported by the remote server")
	// ErrInvalidRange is returned by Read when trying to read past the end of the file
	ErrInvalidRange = errors.New("Invalid range")
)

Functions

func DeleteFile

func DeleteFile(master string, fileId string, jwt security.EncodedJwt) error

func GetVolumeIdxEntries

func GetVolumeIdxEntries(server string, vid string, eachEntryFn func(key uint64, offset, size uint32)) error

func GzipData

func GzipData(input []byte) ([]byte, error)

func IsGzippable

func IsGzippable(ext, mtype string) bool

* Default more not to gzip since gzip can be done on client side.

func ListMasters

func ListMasters(server string) (leader string, peers []string, err error)

func LookupFileId

func LookupFileId(server string, fileId string) (fullUrl string, err error)

func LookupVolumeIds

func LookupVolumeIds(server string, vids []string) (map[string]LookupResult, error)

LookupVolumeIds find volume locations by cache and actual lookup

func ParseFileId

func ParseFileId(fid string) (vid string, key_cookie string, err error)

func UnGzipData

func UnGzipData(input []byte) ([]byte, error)

Types

type AssignResult

type AssignResult struct {
	Fid       string `json:"fid,omitempty"`
	Url       string `json:"url,omitempty"`
	PublicUrl string `json:"publicUrl,omitempty"`
	Count     uint64 `json:"count,omitempty"`
	Error     string `json:"error,omitempty"`
}

func Assign

func Assign(server string, r *VolumeAssignRequest) (*AssignResult, error)

type ChunkInfo

type ChunkInfo struct {
	Fid    string `json:"fid"`
	Offset int64  `json:"offset"`
	Size   int64  `json:"size"`
}

type ChunkList

type ChunkList []*ChunkInfo

func (ChunkList) Len

func (s ChunkList) Len() int

func (ChunkList) Less

func (s ChunkList) Less(i, j int) bool

func (ChunkList) Swap

func (s ChunkList) Swap(i, j int)

type ChunkManifest

type ChunkManifest struct {
	Name   string    `json:"name,omitempty"`
	Mime   string    `json:"mime,omitempty"`
	Size   int64     `json:"size,omitempty"`
	Chunks ChunkList `json:"chunks,omitempty"`
}

func LoadChunkManifest

func LoadChunkManifest(buffer []byte, isGzipped bool) (*ChunkManifest, error)

func (*ChunkManifest) DeleteChunks

func (cm *ChunkManifest) DeleteChunks(master string) error

func (*ChunkManifest) Marshal

func (cm *ChunkManifest) Marshal() ([]byte, error)

type ChunkedFileReader

type ChunkedFileReader struct {
	Manifest *ChunkManifest
	Master   string
	// contains filtered or unexported fields
}

seekable chunked file reader

func (*ChunkedFileReader) Close

func (cf *ChunkedFileReader) Close() (e error)

func (*ChunkedFileReader) Read

func (cf *ChunkedFileReader) Read(p []byte) (int, error)

func (*ChunkedFileReader) ReadAt

func (cf *ChunkedFileReader) ReadAt(p []byte, off int64) (n int, err error)

func (*ChunkedFileReader) Seek

func (cf *ChunkedFileReader) Seek(offset int64, whence int) (int64, error)

func (*ChunkedFileReader) WriteTo

func (cf *ChunkedFileReader) WriteTo(w io.Writer) (n int64, err error)

type ClusterStatusResult

type ClusterStatusResult struct {
	IsLeader bool     `json:"IsLeader,omitempty"`
	Leader   string   `json:"Leader,omitempty"`
	Peers    []string `json:"Peers,omitempty"`
}

type DeleteFilesResult

type DeleteFilesResult struct {
	Errors  []string
	Results []DeleteResult
}

func DeleteFiles

func DeleteFiles(master string, fileIds []string) (*DeleteFilesResult, error)

type DeleteResult

type DeleteResult struct {
	Fid    string `json:"fid"`
	Size   int    `json:"size"`
	Status int    `json:"status"`
	Error  string `json:"error,omitempty"`
}

type FilePart

type FilePart struct {
	Reader      io.Reader
	FileName    string
	FileSize    int64
	IsGzipped   bool
	MimeType    string
	ModTime     int64 //in seconds
	Replication string
	Collection  string
	DataCenter  string
	Ttl         string
	Server      string //this comes from assign result
	Fid         string //this comes from assign result, but customizable
}

func NewFileParts

func NewFileParts(fullPathFilenames []string) (ret []FilePart, err error)

func (FilePart) Upload

func (fi FilePart) Upload(maxMB int, master string, secret security.Secret) (retSize uint32, err error)

type JoinResult

type JoinResult struct {
	VolumeSizeLimit uint64 `json:"VolumeSizeLimit,omitempty"`
	SecretKey       string `json:"secretKey,omitempty"`
	Error           string `json:"error,omitempty"`
}

type Location

type Location struct {
	Url       string `json:"url,omitempty"`
	PublicUrl string `json:"publicUrl,omitempty"`
}

type LookupResult

type LookupResult struct {
	VolumeId  string     `json:"volumeId,omitempty"`
	Locations []Location `json:"locations,omitempty"`
	Error     string     `json:"error,omitempty"`
}

func Lookup

func Lookup(server string, vid string) (ret *LookupResult, err error)

func (*LookupResult) String

func (lr *LookupResult) String() string

type SubmitResult

type SubmitResult struct {
	FileName string `json:"fileName,omitempty"`
	FileUrl  string `json:"fileUrl,omitempty"`
	Fid      string `json:"fid,omitempty"`
	Size     uint32 `json:"size,omitempty"`
	Error    string `json:"error,omitempty"`
}

func SubmitFiles

func SubmitFiles(master string, files []FilePart,
	replication string, collection string, dataCenter string, ttl string, maxMB int,
	secret security.Secret,
) ([]SubmitResult, error)

type SyncVolumeResponse

type SyncVolumeResponse struct {
	Replication     string `json:"Replication,omitempty"`
	Ttl             string `json:"Ttl,omitempty"`
	TailOffset      uint64 `json:"TailOffset,omitempty"`
	CompactRevision uint16 `json:"CompactRevision,omitempty"`
	IdxFileSize     uint64 `json:"IdxFileSize,omitempty"`
	Error           string `json:"error,omitempty"`
}

func GetVolumeSyncStatus

func GetVolumeSyncStatus(server string, vid string) (*SyncVolumeResponse, error)

type UploadResult

type UploadResult struct {
	Name  string `json:"name,omitempty"`
	Size  uint32 `json:"size,omitempty"`
	Error string `json:"error,omitempty"`
}

func Upload

func Upload(uploadUrl string, filename string, reader io.Reader, isGzipped bool, mtype string, pairMap map[string]string, jwt security.EncodedJwt) (*UploadResult, error)

type VidCache

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

func (*VidCache) Get

func (vc *VidCache) Get(vid string) ([]Location, error)

func (*VidCache) Set

func (vc *VidCache) Set(vid string, locations []Location, duration time.Duration)

type VidInfo

type VidInfo struct {
	Locations       []Location
	NextRefreshTime time.Time
}

type VolumeAssignRequest

type VolumeAssignRequest struct {
	Count       uint64
	Replication string
	Collection  string
	Ttl         string
	DataCenter  string
	Rack        string
	DataNode    string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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