disk

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 8 Imported by: 28 modules, 25 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	LineBreak = "\r\n"
)

Variables

This section is empty.

Functions

func GetEscapedPath added in v0.7.0

func GetEscapedPath(dataDir string, fname string) string

Types

type FileLock

type FileLock struct {
	// contains filtered or unexported fields
}

FileLock wraps os.File to be used as a lock using flock

func NewFileLock

func NewFileLock(lockPath string) (*FileLock, error)

NewFileLock opens file/dir at path and returns unlocked FileLock object

func (*FileLock) Close

func (l *FileLock) Close() error

func (*FileLock) Lock

func (l *FileLock) Lock() error

Lock acquires an exclusive lock

func (*FileLock) Unlock

func (l *FileLock) Unlock() error

Unlock releases the lock

type Store

type Store struct {
	*FileLock
	// contains filtered or unexported fields
}

Store is a simple disk-backed store that creates one file per IP address in a given directory. The contents of the file are the container ID.

func New

func New(network, dataDir string) (*Store, error)

func (*Store) FindByID added in v0.8.0

func (s *Store) FindByID(id string, ifname string) bool

func (*Store) FindByKey added in v0.8.0

func (s *Store) FindByKey(match string) (bool, error)

func (*Store) GetByID added in v0.8.2

func (s *Store) GetByID(id string, ifname string) []net.IP

GetByID returns the IPs which have been allocated to the specific ID

func (*Store) LastReservedIP added in v0.6.0

func (s *Store) LastReservedIP(rangeID string) (net.IP, error)

LastReservedIP returns the last reserved IP if exists

func (*Store) ReleaseByID

func (s *Store) ReleaseByID(id string, ifname string) error

N.B. This function eats errors to be tolerant and release as much as possible

func (*Store) ReleaseByKey added in v0.8.0

func (s *Store) ReleaseByKey(match string) (bool, error)

func (*Store) Reserve

func (s *Store) Reserve(id string, ifname string, ip net.IP, rangeID string) (bool, error)

Jump to

Keyboard shortcuts

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