Documentation ¶
Index ¶
- Constants
- Variables
- func GetActualSize(size Size, version Version) int64
- func NeedleBodyLength(needleSize Size, version Version) int64
- func PaddingLength(needleSize Size, version Version) Size
- func ParseNeedleIdCookie(key_hash_string string) (NeedleId, Cookie, error)
- func ReadNeedleBlob(r backend.BackendStorageFile, offset int64, size Size, version Version) (dataSlice []byte, err error)
- func SecondsToTTL(seconds int32) string
- func WriteNeedleBlob(w backend.BackendStorageFile, dataSlice []byte, size Size, appendAtNs uint64, ...) (offset uint64, err error)
- type AsyncRequest
- func (r *AsyncRequest) Complete(offset uint64, size uint64, isUnchanged bool, err error)
- func (r *AsyncRequest) IsSucceed() bool
- func (r *AsyncRequest) Submit()
- func (r *AsyncRequest) UpdateResult(offset uint64, size uint64, isUnchanged bool, err error)
- func (r *AsyncRequest) WaitComplete() (uint64, uint64, bool, error)
- type CRC
- type CRCwriter
- type FileId
- type Needle
- func (n *Needle) Append(w backend.BackendStorageFile, version Version) (offset uint64, size Size, actualSize int64, err error)
- func (n *Needle) DiskSize(version Version) int64
- func (n *Needle) Etag() string
- func (n *Needle) HasLastModifiedDate() bool
- func (n *Needle) HasMime() bool
- func (n *Needle) HasName() bool
- func (n *Needle) HasPairs() bool
- func (n *Needle) HasTtl() bool
- func (n *Needle) IsChunkedManifest() bool
- func (n *Needle) IsCompressed() bool
- func (n *Needle) LastModifiedString() string
- func (n *Needle) ParseNeedleHeader(bytes []byte)
- func (n *Needle) ParsePath(fid string) (err error)
- func (n *Needle) ReadBytes(bytes []byte, offset int64, size Size, version Version) (err error)
- func (n *Needle) ReadData(r backend.BackendStorageFile, offset int64, size Size, version Version) (err error)
- func (n *Needle) ReadNeedleBody(r backend.BackendStorageFile, version Version, offset int64, bodyLength int64) (bytes []byte, err error)
- func (n *Needle) ReadNeedleBodyBytes(needleBody []byte, version Version) (err error)
- func (n *Needle) SetHasLastModifiedDate()
- func (n *Needle) SetHasMime()
- func (n *Needle) SetHasName()
- func (n *Needle) SetHasPairs()
- func (n *Needle) SetHasTtl()
- func (n *Needle) SetIsChunkManifest()
- func (n *Needle) SetIsCompressed()
- func (n *Needle) String() (str string)
- type ParsedUpload
- type TTL
- type Version
- type VolumeId
Constants ¶
View Source
const ( NeedleChecksumSize = 4 PairNamePrefix = "Seaweed-" )
View Source
const ( FlagIsCompressed = 0x01 FlagHasName = 0x02 FlagHasMime = 0x04 FlagHasLastModifiedDate = 0x08 FlagHasTtl = 0x10 FlagHasPairs = 0x20 FlagIsChunkManifest = 0x80 LastModifiedBytesLength = 5 TtlBytesLength = 2 )
View Source
const ( // stored unit types Empty byte = iota Minute Hour Day Week Month Year )
View Source
const ( Version1 = Version(1) Version2 = Version(2) Version3 = Version(3) CurrentVersion = Version3 )
Variables ¶
View Source
var EMPTY_TTL = &TTL{}
View Source
var ErrorSizeMismatch = errors.New("size mismatch")
Functions ¶
func GetActualSize ¶
func NeedleBodyLength ¶
func PaddingLength ¶
func PaddingLength(needleSize Size, version Version) Size
func ParseNeedleIdCookie ¶
func ReadNeedleBlob ¶
func SecondsToTTL ¶
func WriteNeedleBlob ¶
Types ¶
type AsyncRequest ¶
type AsyncRequest struct { N *Needle IsWriteRequest bool ActualSize int64 // contains filtered or unexported fields }
func NewAsyncRequest ¶
func NewAsyncRequest(n *Needle, isWriteRequest bool) *AsyncRequest
func (*AsyncRequest) Complete ¶
func (r *AsyncRequest) Complete(offset uint64, size uint64, isUnchanged bool, err error)
func (*AsyncRequest) IsSucceed ¶
func (r *AsyncRequest) IsSucceed() bool
func (*AsyncRequest) Submit ¶
func (r *AsyncRequest) Submit()
func (*AsyncRequest) UpdateResult ¶
func (r *AsyncRequest) UpdateResult(offset uint64, size uint64, isUnchanged bool, err error)
func (*AsyncRequest) WaitComplete ¶
func (r *AsyncRequest) WaitComplete() (uint64, uint64, bool, error)
type CRCwriter ¶
type CRCwriter struct {
// contains filtered or unexported fields
}
func NewCRCwriter ¶
type FileId ¶
type FileId struct { VolumeId VolumeId Key NeedleId Cookie Cookie }
func NewFileIdFromNeedle ¶
func ParseFileIdFromString ¶
Deserialize the file id
func (*FileId) GetNeedleId ¶
func (n *FileId) GetNeedleId() NeedleId
func (*FileId) GetNeedleIdCookie ¶
func (*FileId) GetVolumeId ¶
type Needle ¶
type Needle struct { Cookie Cookie `comment:"random number to mitigate brute force lookups"` Id NeedleId `comment:"needle id"` Size Size `comment:"sum of DataSize,Data,NameSize,Name,MimeSize,Mime"` DataSize uint32 `comment:"Data size"` //version2 Data []byte `comment:"The actual file data"` Flags byte `comment:"boolean flags"` //version2 NameSize uint8 //version2 Name []byte `comment:"maximum 255 characters"` //version2 MimeSize uint8 //version2 Mime []byte `comment:"maximum 255 characters"` //version2 PairsSize uint16 //version2 Pairs []byte `comment:"additional name value pairs, json format, maximum 64kB"` LastModified uint64 //only store LastModifiedBytesLength bytes, which is 5 bytes to disk Ttl *TTL Checksum CRC `comment:"CRC32 to check integrity"` AppendAtNs uint64 `comment:"append timestamp in nano seconds"` //version3 Padding []byte `comment:"Aligned to 8 bytes"` }
* A Needle means a uploaded and stored file. * Needle file size is limited to 4GB for now.
func CreateNeedleFromRequest ¶
func ReadNeedleHeader ¶
func (*Needle) HasLastModifiedDate ¶
func (*Needle) IsChunkedManifest ¶
func (*Needle) IsCompressed ¶
func (*Needle) LastModifiedString ¶
func (*Needle) ParseNeedleHeader ¶
func (*Needle) ReadBytes ¶
ReadBytes hydrates the needle from the bytes buffer, with only n.Id is set.
func (*Needle) ReadData ¶
func (n *Needle) ReadData(r backend.BackendStorageFile, offset int64, size Size, version Version) (err error)
ReadData hydrates the needle from the file, with only n.Id is set.
func (*Needle) ReadNeedleBody ¶
func (n *Needle) ReadNeedleBody(r backend.BackendStorageFile, version Version, offset int64, bodyLength int64) (bytes []byte, err error)
n should be a needle already read the header the input stream will read until next file entry
func (*Needle) ReadNeedleBodyBytes ¶
func (*Needle) SetHasLastModifiedDate ¶
func (n *Needle) SetHasLastModifiedDate()
func (*Needle) SetHasMime ¶
func (n *Needle) SetHasMime()
func (*Needle) SetHasName ¶
func (n *Needle) SetHasName()
func (*Needle) SetHasPairs ¶
func (n *Needle) SetHasPairs()
func (*Needle) SetIsChunkManifest ¶
func (n *Needle) SetIsChunkManifest()
func (*Needle) SetIsCompressed ¶
func (n *Needle) SetIsCompressed()
type ParsedUpload ¶
type ParsedUpload struct { FileName string Data []byte MimeType string PairMap map[string]string IsGzipped bool // IsZstd bool OriginalDataSize int ModifiedTime uint64 Ttl *TTL IsChunkedFile bool UncompressedData []byte ContentMd5 string // contains filtered or unexported fields }
func ParseUpload ¶
Click to show internal directories.
Click to hide internal directories.