Documentation ¶
Index ¶
- Variables
- func MakeSubnetKey(sn ip.IP4Net) string
- func ParseSubnetKey(s string) *ip.IP4Net
- func WatchLease(ctx context.Context, sm Manager, sn ip.IP4Net, receiver chan Event)
- func WatchLeases(ctx context.Context, sm Manager, ownLease *Lease, receiver chan []Event)
- type Config
- type Event
- type EventType
- type Lease
- type LeaseAttrs
- type LeaseWatchResult
- type Manager
- type Reservation
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrLeaseTaken = errors.New("subnet: lease already taken") ErrNoMoreTries = errors.New("subnet: no more tries") )
Functions ¶
func MakeSubnetKey ¶ added in v0.5.6
func ParseSubnetKey ¶ added in v0.5.6
func WatchLease ¶ added in v0.5.6
WatchLease performs a long term watch of the given network's subnet lease and communicates addition/deletion events on receiver channel. It takes care of handling "fall-behind" logic where the history window has advanced too far and it needs to diff the latest snapshot with its saved state and generate events
func WatchLeases ¶ added in v0.5.0
WatchLeases performs a long term watch of the given network's subnet leases and communicates addition/deletion events on receiver channel. It takes care of handling "fall-behind" logic where the history window has advanced too far and it needs to diff the latest snapshot with its saved state and generate events
Types ¶
type Config ¶
type Config struct { Network ip.IP4Net SubnetMin ip.IP4 SubnetMax ip.IP4 SubnetLen uint BackendType string `json:"-"` Backend json.RawMessage `json:",omitempty"` }
func ParseConfig ¶
type EventType ¶
type EventType int
func (EventType) MarshalJSON ¶ added in v0.5.0
func (*EventType) UnmarshalJSON ¶ added in v0.5.0
type LeaseAttrs ¶ added in v0.2.0
type LeaseAttrs struct { PublicIP ip.IP4 BackendType string `json:",omitempty"` BackendData json.RawMessage `json:",omitempty"` }
type LeaseWatchResult ¶ added in v0.5.6
type LeaseWatchResult struct { // Either Events or Snapshot will be set. If Events is empty, it means // the cursor was out of range and Snapshot contains the current list // of items, even if empty. Events []Event `json:"events"` Snapshot []Lease `json:"snapshot"` Cursor interface{} `json:"cursor"` }
type Manager ¶ added in v0.5.0
type Manager interface { GetNetworkConfig(ctx context.Context) (*Config, error) AcquireLease(ctx context.Context, attrs *LeaseAttrs) (*Lease, error) RenewLease(ctx context.Context, lease *Lease) error RevokeLease(ctx context.Context, sn ip.IP4Net) error WatchLease(ctx context.Context, sn ip.IP4Net, cursor interface{}) (LeaseWatchResult, error) WatchLeases(ctx context.Context, cursor interface{}) (LeaseWatchResult, error) AddReservation(ctx context.Context, r *Reservation) error RemoveReservation(ctx context.Context, subnet ip.IP4Net) error ListReservations(ctx context.Context) ([]Reservation, error) }
Click to show internal directories.
Click to hide internal directories.