writeback

package
v0.0.0-...-b4aeae5 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package writeback keeps track of the files which need to be written back to storage

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handle

type Handle uint64

Handle is returned for callers to keep track of writeback items

type PutFn

type PutFn func(context.Context) error

PutFn is the interface that item provides to store the data

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 New

func New(ctx context.Context, opt *vfscommon.Options) *WriteBack

New make a new WriteBack

cancel the context to stop the background processing

func (*WriteBack) Add

func (wb *WriteBack) Add(id Handle, name string, modified bool, putFn PutFn) Handle

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

func (wb *WriteBack) Remove(id Handle) (found bool)

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

func (wb *WriteBack) Rename(id Handle, name string)

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) SetID

func (wb *WriteBack) SetID(pid *Handle)

SetID sets the Handle pointed to if it is non zero to the next handle.

func (*WriteBack) Stats

func (wb *WriteBack) Stats() (uploadsInProgress, uploadsQueued int)

Stats return the number of uploads in progress and queued

Jump to

Keyboard shortcuts

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