Documentation
¶
Overview ¶
Package IPAM provides IPv4 address allocation against the mesh database.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoNetwork is returned when no network is configured. ErrNoNetwork = fmt.Errorf("no network configured") // ErrNoStorage is returned when no storage is configured. ErrNoStorage = fmt.Errorf("no storage configured") )
Functions ¶
This section is empty.
Types ¶
type Allocator ¶
type Allocator interface {
// Allocate allocates an IP address for the given node ID.
Allocate(ctx context.Context, nodeID meshtypes.NodeID) (netip.Prefix, error)
// Locker returns the underlying Locker. Locks should be acquired before
// calls to allocate. They are provided as separate methods to ensure
// the caller has time to write the allocation to the DB. Allocate simply
// observes the current state and respond with an available address.
Locker() Locker
}
Allocator is the interface for an IPAM allocator.
type Config ¶
type Config struct {
// IPAM is the IPAM configuration.
IPAM meshplugins.IPAMConfig
// Lock is the lock configuration.
Lock LockConfig
// Network is the IPv4 network to allocate addresses in.
Network netip.Prefix
}
Config is the configuration for the allocator.
type LockConfig ¶
type LockConfig struct {
ID string
Namespace string
LockDuration time.Duration
LockAcquireTimeout time.Duration
}
LockConfig is the configuration for a lock.
type Locker ¶
type Locker interface {
// Acquire attempts to acquire the lock. If a lock is already acquired, the
// lock count is incremented. When the lock is released, the lock count is
// decremented. When the lock count reaches 0, the lock is released.
Acquire(ctx context.Context) error
// Release releases the lock. This decrements the lock count. When the lock
// count reaches 0, the lock is released.
Release(ctx context.Context)
}
Locker is the interface for taking a distributed lock during IPv4 allocations.
Click to show internal directories.
Click to hide internal directories.