store

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrReservationAlreadyExist is returned when reservation for id and interface already exist in the pool
	ErrReservationAlreadyExist = errors.New("reservation already exist, " +
		"duplicate allocations are not allowed by the spec")
	// ErrIPAlreadyReserved is returned when trying to reserve IP which is already reserved
	ErrIPAlreadyReserved = errors.New("ip address is already reserved")
)

Functions

This section is empty.

Types

type Session

type Session interface {
	// Reserve reserves IP for the id and interface name,
	// returns error if allocation failed
	Reserve(poolKey string, id string, ifName string, meta types.ReservationMetadata, address net.IP) error
	// ListReservations list all reservations in the pool
	ListReservations(poolKey string) []types.Reservation
	// ListPools return list with names of all known pools
	ListPools() []string
	// RemovePool removes information about the pool from the store
	RemovePool(poolKey string)
	// GetLastReservedIP returns last reserved IP for the pool or nil
	GetLastReservedIP(poolKey string) net.IP
	// SetLastReservedIP set last reserved IP fot the pool
	SetLastReservedIP(poolKey string, ip net.IP)
	// ReleaseReservationByID releases reservation by id and interface name
	ReleaseReservationByID(poolKey string, id string, ifName string)
	// GetReservationByID returns existing reservation for id and interface name,
	// return nil if allocation not found
	GetReservationByID(poolKey string, id string, ifName string) *types.Reservation
	// Commit writes persistedData to the disk and release the lock.
	// the store can't be used after this call
	Commit() error
	// Cancel cancels all modifications and release the lock
	// the store can't be used after this call
	Cancel()
}

Session is the interface implemented by the store package

type Store

type Store interface {
	// Open returns a session for the store with exclusive lock.
	// returns an error if failed to read persistedData from the disk.
	// Open blocks if another Session is already opened.
	// Session.Commit() should be called to close the session, release the lock and write changes to disk and
	// Session.Cancel() can be called to close the session, revert all changes and release the lock
	Open(ctx context.Context) (Session, error)
}

Store implements API to open file store in exclusive mode

func New

func New(storeFile string) Store

New create and initialize new store instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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