fs

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 18, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

package fs is for interacting with file systems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedVolumeUsageCalculator

type CachedVolumeUsageCalculator struct {
	UsageCalculator VolumeUsageCalculator
	// contains filtered or unexported fields
}

CachedVolumeUsageCalculator wraps a VolumeUsageCalculator to provide an in-memory cache for the Size() method.

func (*CachedVolumeUsageCalculator) Free

func (v *CachedVolumeUsageCalculator) Free(ctx context.Context, volumePath string) uint64

Free returns the free space of the volume in bytes.

func (*CachedVolumeUsageCalculator) Size

func (v *CachedVolumeUsageCalculator) Size(ctx context.Context, volumePath string) uint64

Size returns the size of the volume in bytes.

type CheckedVolumeUsageCalculator

type CheckedVolumeUsageCalculator struct {
	// Retries is the number of attempts at getting the free space that should
	// be made, if the answer is 0
	Retries int

	// Backoff determines the time waited in between attempts. It will be
	// Reset() when free space is greater than 0.
	Backoff *backoff.Backoff

	// UsageCalculator is an implementation of VolumeUsageCalculator.
	UsageCalculator VolumeUsageCalculator
}

CheckedVolumeUsageCalculator wraps a VolumeUsageCalculator to confirm multiple times when free space on the volume is reported as 0, before returning that answer.

func (*CheckedVolumeUsageCalculator) Free

func (v *CheckedVolumeUsageCalculator) Free(ctx context.Context, volumePath string) uint64

Free returns the free space of the volume in bytes. If the answer would be 0, this is first re-confirmed multiple times before returning.

func (*CheckedVolumeUsageCalculator) Size

func (v *CheckedVolumeUsageCalculator) Size(ctx context.Context, volumePath string) uint64

Size returns the size of the volume in bytes. If the answer would be 0, this is first re-confirmed multiple times before returning.

type Volume

type Volume struct {
	// Dir is a directory path mounted on the volume of interest. "." is taken
	// to mean the current directory.
	Dir string

	// UsageCalculator is an implementation of VolumeUsageCalculator.
	UsageCalculator VolumeUsageCalculator
}

Volume respresents a file system volume.

func (*Volume) NoSpaceLeft

func (v *Volume) NoSpaceLeft(ctx context.Context) bool

NoSpaceLeft tells you if the volume has no more space left (or is within 100MB of being full).

func (*Volume) Size

func (v *Volume) Size(ctx context.Context) int

Size returns the size of the volume in GB.

type VolumeUsageCalculator

type VolumeUsageCalculator interface {
	// Size returns the size of the volume in bytes.
	Size(ctx context.Context, volumePath string) uint64

	// Free returns the free space of the volume in bytes.
	Free(ctx context.Context, volumePath string) uint64
}

VolumeUsageCalculator has methods that provide volume usage information.

Directories

Path Synopsis
package local contains a local implementation of VolumeUsageCalculator.
package local contains a local implementation of VolumeUsageCalculator.
package mock contains a mock implementation of VolumeUsageCalculator.
package mock contains a mock implementation of VolumeUsageCalculator.

Jump to

Keyboard shortcuts

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