subnet

package
v0.0.0-...-c283e9f Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2021 License: BSD-3-Clause, Apache-2.0 Imports: 12 Imported by: 10

Documentation

Index

Constants

View Source
const (
	SubnetAdded = iota
	SubnetRemoved
)

Variables

View Source
var (
	ErrSubnetExists = errors.New("subnet exists")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Network   ip.IP4Net
	SubnetMin ip.IP4
	SubnetMax ip.IP4
	SubnetLen uint
	Backend   json.RawMessage
}

func ParseConfig

func ParseConfig(data []byte) (*Config, error)

type Event

type Event struct {
	Type  EventType
	Lease SubnetLease
}

type EventBatch

type EventBatch []Event

type EventType

type EventType int

type LeaseAttrs

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

type Registry

type Registry interface {
	GetConfig() ([]byte, error)
	GetSubnets() (*Response, error)
	CreateSubnet(sn, data string, ttl uint64) (*Response, error)
	UpdateSubnet(sn, data string, ttl uint64) (*Response, error)
	WatchSubnets(since uint64, stop chan bool) (*Response, error)
}

type Response

type Response struct {
	Subnets    map[string][]byte
	Index      uint64
	Expiration *time.Time
	Action     string
}

type SubnetLease

type SubnetLease struct {
	Network ip.IP4Net
	Attrs   LeaseAttrs
}

type SubnetManager

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

func NewSubnetManager

func NewSubnetManager(r Registry) (*SubnetManager, error)

func (*SubnetManager) AcquireLease

func (sm *SubnetManager) AcquireLease(attrs *LeaseAttrs, cancel chan bool) (ip.IP4Net, error)

func (*SubnetManager) GetConfig

func (sm *SubnetManager) GetConfig() *Config

func (*SubnetManager) Lease

func (sm *SubnetManager) Lease() SubnetLease

func (*SubnetManager) LeaseRenewer

func (sm *SubnetManager) LeaseRenewer(cancel chan bool)

func (*SubnetManager) Leases

func (sm *SubnetManager) Leases() []SubnetLease

func (*SubnetManager) WatchLeases

func (sm *SubnetManager) WatchLeases(receiver chan EventBatch, cancel chan bool)

Jump to

Keyboard shortcuts

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