Documentation ¶
Index ¶
- Constants
- Variables
- func MakeSubnetKey(sn ip.IP4Net) string
- func ParseSubnetKey(s string) *ip.IP4Net
- func WatchLease(ctx context.Context, sm Manager, network string, sn ip.IP4Net, ...)
- func WatchLeases(ctx context.Context, sm Manager, network string, ownLease *Lease, ...)
- func WatchNetworks(ctx context.Context, sm Manager, receiver chan []Event)
- type Config
- type EtcdConfig
- type Event
- type EventType
- type Lease
- type LeaseAttrs
- type LeaseWatchResult
- type LocalManager
- func (m *LocalManager) AcquireLease(ctx context.Context, network string, attrs *LeaseAttrs) (*Lease, error)
- func (m *LocalManager) AddReservation(ctx context.Context, network string, r *Reservation) error
- func (m *LocalManager) GetNetworkConfig(ctx context.Context, network string) (*Config, error)
- func (m *LocalManager) ListReservations(ctx context.Context, network string) ([]Reservation, error)
- func (m *LocalManager) RemoveReservation(ctx context.Context, network string, subnet ip.IP4Net) error
- func (m *LocalManager) RenewLease(ctx context.Context, network string, lease *Lease) error
- func (m *LocalManager) RevokeLease(ctx context.Context, network string, sn ip.IP4Net) error
- func (m *LocalManager) WatchLease(ctx context.Context, network string, sn ip.IP4Net, cursor interface{}) (LeaseWatchResult, error)
- func (m *LocalManager) WatchLeases(ctx context.Context, network string, cursor interface{}) (LeaseWatchResult, error)
- func (m *LocalManager) WatchNetworks(ctx context.Context, cursor interface{}) (NetworkWatchResult, error)
- type Manager
- type MockSubnetRegistry
- type NetworkWatchResult
- type Registry
- type Reservation
Constants ¶
const DEFAULT_TTL time.Duration = 8760 * time.Hour // one year
Variables ¶
var ( ErrLeaseTaken = errors.New("subnet: lease already taken") ErrNoMoreTries = errors.New("subnet: no more tries") )
Functions ¶
func MakeSubnetKey ¶ added in v0.6.0
func ParseSubnetKey ¶ added in v0.6.0
func WatchLease ¶ added in v0.6.0
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
func WatchLeases(ctx context.Context, sm Manager, network string, ownLease *Lease, receiver chan []Event)
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
func WatchNetworks ¶ added in v0.6.0
WatchNetworks performs a long term watch of flannel networks 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 EtcdConfig ¶ added in v0.2.0
type EventType ¶
type EventType int
func (EventType) MarshalJSON ¶ added in v0.5.0
func (*EventType) UnmarshalJSON ¶ added in v0.5.0
type Lease ¶ added in v0.5.0
type Lease struct { Subnet ip.IP4Net Attrs LeaseAttrs Expiration time.Time // contains filtered or unexported fields }
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.6.0
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 LocalManager ¶ added in v0.6.0
type LocalManager struct {
// contains filtered or unexported fields
}
func (*LocalManager) AcquireLease ¶ added in v0.6.0
func (m *LocalManager) AcquireLease(ctx context.Context, network string, attrs *LeaseAttrs) (*Lease, error)
func (*LocalManager) AddReservation ¶ added in v0.6.0
func (m *LocalManager) AddReservation(ctx context.Context, network string, r *Reservation) error
func (*LocalManager) GetNetworkConfig ¶ added in v0.6.0
func (*LocalManager) ListReservations ¶ added in v0.6.0
func (m *LocalManager) ListReservations(ctx context.Context, network string) ([]Reservation, error)
func (*LocalManager) RemoveReservation ¶ added in v0.6.0
func (m *LocalManager) RemoveReservation(ctx context.Context, network string, subnet ip.IP4Net) error
RemoveReservation removes the subnet by setting TTL back to subnetTTL (24hours)
func (*LocalManager) RenewLease ¶ added in v0.6.0
func (*LocalManager) RevokeLease ¶ added in v0.6.0
func (*LocalManager) WatchLease ¶ added in v0.6.0
func (m *LocalManager) WatchLease(ctx context.Context, network string, sn ip.IP4Net, cursor interface{}) (LeaseWatchResult, error)
func (*LocalManager) WatchLeases ¶ added in v0.6.0
func (m *LocalManager) WatchLeases(ctx context.Context, network string, cursor interface{}) (LeaseWatchResult, error)
func (*LocalManager) WatchNetworks ¶ added in v0.6.0
func (m *LocalManager) WatchNetworks(ctx context.Context, cursor interface{}) (NetworkWatchResult, error)
type Manager ¶ added in v0.5.0
type Manager interface { GetNetworkConfig(ctx context.Context, network string) (*Config, error) AcquireLease(ctx context.Context, network string, attrs *LeaseAttrs) (*Lease, error) RenewLease(ctx context.Context, network string, lease *Lease) error RevokeLease(ctx context.Context, network string, sn ip.IP4Net) error WatchLease(ctx context.Context, network string, sn ip.IP4Net, cursor interface{}) (LeaseWatchResult, error) WatchLeases(ctx context.Context, network string, cursor interface{}) (LeaseWatchResult, error) WatchNetworks(ctx context.Context, cursor interface{}) (NetworkWatchResult, error) AddReservation(ctx context.Context, network string, r *Reservation) error RemoveReservation(ctx context.Context, network string, subnet ip.IP4Net) error ListReservations(ctx context.Context, network string) ([]Reservation, error) }
func NewLocalManager ¶ added in v0.6.0
func NewLocalManager(config *EtcdConfig) (Manager, error)
func NewMockManager ¶ added in v0.5.0
func NewMockManager(registry *MockSubnetRegistry) Manager
type MockSubnetRegistry ¶ added in v0.6.0
type MockSubnetRegistry struct {
// contains filtered or unexported fields
}
func NewMockRegistry ¶ added in v0.6.0
func NewMockRegistry(network, config string, initialSubnets []Lease) *MockSubnetRegistry
func (*MockSubnetRegistry) CreateNetwork ¶ added in v0.6.0
func (msr *MockSubnetRegistry) CreateNetwork(ctx context.Context, network, config string) error
func (*MockSubnetRegistry) DeleteNetwork ¶ added in v0.6.0
func (msr *MockSubnetRegistry) DeleteNetwork(ctx context.Context, network string) error
type NetworkWatchResult ¶ added in v0.6.0
type NetworkWatchResult 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 []string `json:"snapshot"` Cursor interface{} `json:"cursor,omitempty"` }