state

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository interface {
	// Find returns the State, if there is no State it'll return an empty State
	Find(ctx context.Context) (*State, error)

	// Update updates the State
	Update(ctx context.Context, s *State) error

	// DeleteAll deletes all the state data
	DeleteAll(ctx context.Context) error
}

Repository are the actions that can be done to modify the volume State

type State

type State struct {
	// The Mountpoint of the volume, so we can make
	// sure it's that if it's also used by
	// another volume we do not repeat Stats
	Mountpoint string

	SystemTotalSize int

	SystemUsedSize int

	// TotalSize is the total size of the volume
	// if not specified then this value will be -1
	VolumeTotalSize int

	// UsedSize is the total used size of the volume objects
	VolumeUsedSize int

	// UpdatedAt is useful to be able to know on restart
	// how long has it been since the last check, it's like
	// a heartbeat
	UpdatedAt time.Time
}

State is the current state in which the volume is

func (*State) CanStore

func (s *State) CanStore(b int) bool

CanStore will check if the b bytes fit into the defined sizes to prevent over sizing

func (*State) IsInDowntimeRange added in v0.3.0

func (s *State) IsInDowntimeRange(d time.Duration) bool

IsInDowntimeRange will check if the s.UpdatedAt plus the duration is older than the current date, meaning it's not on range

func (*State) TotalSize

func (s *State) TotalSize() int

TotalSize returns the total size depending if the VolumeTotalSize is set or not

func (*State) Use

func (s *State) Use(b int) bool

Use will try to set b if it fits

func (*State) UsedSize

func (s *State) UsedSize() int

UsedSize returns the used size depending if the VolumeTotalSize is set or not

Jump to

Keyboard shortcuts

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