etcdmanager

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunNetnsWatch

func RunNetnsWatch(ctx context.Context, sm EtcdManager, network string, receiver chan []Event, handle func(batch []Event))

func RunSubnetWatch

func RunSubnetWatch(ctx context.Context, sm EtcdManager, network string, receiver chan []Event, handle func(batch []Event))

func WatchNetNamespaces

func WatchNetNamespaces(ctx context.Context, sm EtcdManager, network string, receiver chan []Event)

WatchNetNamespaces performs a long term watch of the given network's netnamespaces 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 WatchSubnets

func WatchSubnets(ctx context.Context, sm EtcdManager, network string, receiver chan []Event)

WatchSubnets performs a long term watch of the given network's subnets 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 ClusterNetwork

type ClusterNetwork struct {
	Name             string
	Network          string
	HostSubnetLength uint32
	ServiceNetwork   string
	PluginName       string
}

type EtcdManager

type EtcdManager interface {
	GetNetworkConfig(ctx context.Context, network string) (*ClusterNetwork, error)
	AcquireSubnet(ctx context.Context, network string, host string, subnet *HostSubnet) error
	GetSubnet(ctx context.Context, network string, host string) (*HostSubnet, error)
	GetNetNamespace(ctx context.Context, network string, namespace string) (*NetNamespace, error)
	GetSubnets(ctx context.Context, network string) ([]HostSubnet, error)
	GetNetNamespaces(ctx context.Context, network string) ([]NetNamespace, error)
	AcquireNetNamespace(ctx context.Context, network string, attrs *NetNamespace) error
	RenewSubnet(ctx context.Context, network string, subnet *HostSubnet) error
	RenewNetNamespace(ctx context.Context, network string, netns *NetNamespace) error
	RevokeSubnet(ctx context.Context, network string, host string) error
	RevokeNetNamespace(ctx context.Context, network string, namespace string) error
	WatchSubnets(ctx context.Context, network string, cursor interface{}) (SubnetWatchResult, error)
	WatchNetNamespaces(ctx context.Context, network string, cursor interface{}) (NetNamespaceWatchResult, error)
}

type Event

type Event struct {
	Type    EventType    `json:"type"`
	Subnet  HostSubnet   `json:"hostsubnet,omitempty"`
	Network string       `json:"network,omitempty"`
	NetNS   NetNamespace `json:"netnamespace,omitempty"`
}

type EventType

type EventType int
const (
	EventAdded EventType = iota
	EventRemoved
)

type HostSubnet

type HostSubnet struct {
	// host may just be an IP address, resolvable hostname or a complete DNS
	Host   string
	HostIP string
	Subnet string
	Assign bool
}

HostSubnet encapsulates the inputs needed to define the container subnet network on a node

type Lease

type Lease struct {
	Host       string
	Attrs      HostSubnet
	Expiration time.Time

	Asof uint64
}

type NetNamespace

type NetNamespace struct {
	NetName   string
	NetID     uint32
	Action    string
	Namespace string
}

NetNamespace holds the network id against its name

type NetNamespaceWatchResult

type NetNamespaceWatchResult 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 []NetNamespace `json:"snapshot"`
	Cursor   interface{}    `json:"cursor"`
}

type NetworkWatchResult

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"`
}

type SubnetWatchResult

type SubnetWatchResult 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 []HostSubnet `json:"snapshot"`
	Cursor   interface{}  `json:"cursor"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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