disk

package
Version: v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: Apache-2.0 Imports: 9 Imported by: 11

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(id string, ifname string, 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) Release

func (s *Store) Release(ip net.IP) error

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(id string, ifname string, match string) (bool, error)

func (*Store) Reserve

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

Source Files

Jump to

Keyboard shortcuts

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