Documentation
¶
Overview ¶
Package snd is an afero sync & delete file system
Index ¶
- Variables
- type Behavior
- type Config
- type File
- type Fs
- func (fs *Fs) Chmod(name string, mode os.FileMode) error
- func (fs *Fs) Chown(name string, uid, gid int) error
- func (fs *Fs) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (fs *Fs) Close() error
- func (fs *Fs) CloseContext(ctx context.Context) error
- func (fs *Fs) MkDir(name string, perm os.FileMode) error
- func (fs *Fs) MkdirAll(path string, perm os.FileMode) error
- func (fs *Fs) Name() string
- func (fs *Fs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)
- func (fs *Fs) Remove(name string) error
- func (fs *Fs) RemoveAll(path string) error
- func (fs *Fs) Rename(oldName, newName string) error
- func (fs *Fs) Sync() error
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("snd file system is closed")
ErrClosed is returned when an operation can't be synced because the file system is closed
var ErrNoDestination = errors.New("destination FS needs to be specified")
ErrNoDestination is returned when the destination is nil
Functions ¶
This section is empty.
Types ¶
type Behavior ¶
type Behavior struct {
FileNbMin *int // Minimum number of files to keep
FileAgeMin time.Duration // Minimum age of a file to be deleted
OperationsQueueSize int // Queue of operations to perform
CleanupPeriod time.Duration // Period of time between cleanups
CloseTimeout time.Duration // Maximum time Close waits for the queued operations (default: 1 minute)
}
Behavior defines the GC logic
type Config ¶
type Config struct {
Destination afero.Fs
Temporary afero.Fs
Behavior *Behavior
Logger *slog.Logger
}
Config defines the SND file system configuration
type File ¶
type File struct {
afero.File // Underlying temporary file
// contains filtered or unexported fields
}
File is the internal representation of a file
type Fs ¶
Fs is the SND file system
func (*Fs) Close ¶
Close the file system. It waits for the operations queued before it to run, at most Behavior.CloseTimeout. It can be called more than once.
func (*Fs) CloseContext ¶ added in v0.3.0
CloseContext closes the file system. It waits for the operations queued before it to run, until the context is done. The operations still queued then keep running in the background. The temporary directory created by NewFs (never one given in the Config) is removed once they have all run.