标签:lease release 源码分析 tin struct rem key return network
// main.go
1、func main()
nm.Run(ctx)
}
// main.go
2、func newSubnetManager() (subnet.Manager, error)
subnet.Manager数据结构如下所示:
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) }
// subnet/etcdv2/local_manager.go
func NewLocalManager(config *EtcdConfig) (Manager, error)
LocalManager的结构如下所示:
type LocalManager struct { registry Registry }
// subnet/etcdv2/registry.go
func newEtcdSubnetRegistry(config *EtcdConfig, cliNewFunc etcdNewFunc) (Registry, error)
etcdCfg: config,
networkRegex: regexp.MustCompile(config.Prefix + `/([^/]*)(/|/config)?$`),
}
etcdSubnetRegistry结构如下所示:
type etcdSubnetRegistry struct { cliNewFunc etcdNewFunc mux sync.Mutex cli etcd.KeysAPI etcdCfg *EtcdConfig networkRegex *regexp.Regexp }
// subnet/etcdv2/registry.go
func newEtcdClien(c *EtcdConfig) (etcd.KeysAPI, error)
// network/manager.go
func NewNetworkManager(ctx context.Context, sm subnet.Manager) (*Manager, error)
ctx: ctx,
sm: sm,
bm: bm,
allowedNetworks: make(map[string]bool),
networks: make(map[string]*Network),
watch: opts.watchNetworks,
ipMasq: opts.ipMasq,
extIface: extIface,
}
// network/manager.go
func lookupExtIface(ifname string) (*backend.ExternalInterface, error)
Iface: iface,
IfaceAddr: ifaceAddr,
ExtAddr: extAddr,
}, nil
标签:lease release 源码分析 tin struct rem key return network
原文地址:http://www.cnblogs.com/YaoDD/p/6556860.html