Documentation ¶
Overview ¶
Package writeback keeps track of the files which need to be written back to storage
Index ¶
- Variables
- type Handle
- type PutFn
- type QueueInfo
- type WriteBack
- func (wb *WriteBack) Add(id Handle, name string, size int64, modified bool, putFn PutFn) Handle
- func (wb *WriteBack) Queue() []QueueInfo
- func (wb *WriteBack) Remove(id Handle) (found bool)
- func (wb *WriteBack) Rename(id Handle, name string)
- func (wb *WriteBack) SetExpiry(id Handle, expiry time.Time) error
- func (wb *WriteBack) SetID(pid *Handle)
- func (wb *WriteBack) Stats() (uploadsInProgress, uploadsQueued int)
Constants ¶
This section is empty.
Variables ¶
var ErrorIDNotFound = errors.New("id not found in queue")
ErrorIDNotFound is returned from SetExpiry when the item is not found
Functions ¶
This section is empty.
Types ¶
type QueueInfo ¶ added in v1.68.0
type QueueInfo struct { Name string `json:"name"` // name (full path) of the file, ID Handle `json:"id"` // id of queue item Size int64 `json:"size"` // integer size of the file in bytes Expiry float64 `json:"expiry"` // seconds from now which the file is eligible for transfer, oldest goes first Tries int `json:"tries"` // number of times we have tried to upload Delay float64 `json:"delay"` // delay between upload attempts (s) Uploading bool `json:"uploading"` // true if item is being uploaded }
QueueInfo is information about an item queued for upload, returned by Queue
type WriteBack ¶
type WriteBack struct {
// contains filtered or unexported fields
}
WriteBack keeps track of the items which need to be written back to the disk at some point
func (*WriteBack) Add ¶
Add adds an item to the writeback queue or resets its timer if it is already there.
If id is 0 then a new item will always be created and the new Handle will be returned.
Use SetID to create Handles in advance of calling Add.
If modified is false then it it doesn't cancel a pending upload if there is one as there is no need.
func (*WriteBack) Remove ¶
Remove should be called when a file should be removed from the writeback queue. This cancels a writeback if there is one and doesn't return the item to the queue.
func (*WriteBack) Rename ¶
Rename should be called when a file might be uploading and it gains a new name. This will cancel the upload and put it back in the queue.
func (*WriteBack) SetExpiry ¶ added in v1.68.0
SetExpiry sets the expiry time for an item in the writeback queue.
id should be as returned from the Queue call
If the item isn't found then it will return ErrorIDNotFound