subnet

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2015 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LeaseRenewer added in v0.5.0

func LeaseRenewer(ctx context.Context, m Manager, network string, lease *Lease)

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

Types

type Config

type Config struct {
	Network   ip.IP4Net
	SubnetMin ip.IP4
	SubnetMax ip.IP4
	SubnetLen uint
	Backend   json.RawMessage `json:",omitempty"`
}

func ParseConfig

func ParseConfig(s string) (*Config, error)

type EtcdConfig added in v0.2.0

type EtcdConfig struct {
	Endpoints []string
	Keyfile   string
	Certfile  string
	CAFile    string
	Prefix    string
}

type EtcdManager added in v0.5.0

type EtcdManager struct {
	// contains filtered or unexported fields
}

func (*EtcdManager) AcquireLease added in v0.5.0

func (m *EtcdManager) AcquireLease(ctx context.Context, network string, attrs *LeaseAttrs) (*Lease, error)

func (*EtcdManager) GetNetworkConfig added in v0.5.0

func (m *EtcdManager) GetNetworkConfig(ctx context.Context, network string) (*Config, error)

func (*EtcdManager) RenewLease added in v0.5.0

func (m *EtcdManager) RenewLease(ctx context.Context, network string, lease *Lease) error

func (*EtcdManager) WatchLeases added in v0.5.0

func (m *EtcdManager) WatchLeases(ctx context.Context, network string, cursor interface{}) (WatchResult, error)

type Event

type Event struct {
	Type  EventType `json:"type"`
	Lease Lease     `json:"lease"`
}

type EventType

type EventType int
const (
	SubnetAdded EventType = iota
	SubnetRemoved
)

func (EventType) MarshalJSON added in v0.5.0

func (et EventType) MarshalJSON() ([]byte, error)

func (*EventType) UnmarshalJSON added in v0.5.0

func (et *EventType) UnmarshalJSON(data []byte) error

type Lease added in v0.5.0

type Lease struct {
	Subnet     ip.IP4Net
	Attrs      *LeaseAttrs
	Expiration time.Time
}

func (*Lease) Key added in v0.5.0

func (l *Lease) Key() string

type LeaseAttrs added in v0.2.0

type LeaseAttrs struct {
	PublicIP    ip.IP4
	BackendType string          `json:",omitempty"`
	BackendData json.RawMessage `json:",omitempty"`
}

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
	WatchLeases(ctx context.Context, network string, cursor interface{}) (WatchResult, error)
}

func NewEtcdManager added in v0.5.0

func NewEtcdManager(config *EtcdConfig) (Manager, error)

func NewMockManager added in v0.5.0

func NewMockManager(ttlOverride time.Duration, config string) Manager

type Registry added in v0.5.0

type Registry interface {
	// contains filtered or unexported methods
}

type WatchResult added in v0.5.0

type WatchResult struct {
	// Either Events or Leases should be set.
	// If Leases are not empty, it means the cursor
	// was out of range and Snapshot contains the current
	// list of leases
	Events   []Event     `json:"events"`
	Snapshot []Lease     `json:"snapshot"`
	Cursor   interface{} `json:"cursor"`
}

Jump to

Keyboard shortcuts

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