Documentation ¶
Overview ¶
Package interfacename contains code implementing NetworkServiceServer and NetworkServiceClient to generate and set the name of the interface in the mechanism and the mechanism preferences of the requests
Index ¶
- Constants
- func NewClient(prefix string, generator NameGenerator) networkservice.NetworkServiceClient
- func NewServer(prefix string, generator NameGenerator) networkservice.NetworkServiceServer
- type CounterGenerator
- type InterfaceNameChache
- type NameGenerator
- type Option
- type RandomGenerator
- type ReleaseTrigger
Constants ¶
const MAX_INTERFACE_NAME_LENGTH = 15
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
func NewClient(prefix string, generator NameGenerator) networkservice.NetworkServiceClient
NewClient implements NetworkServiceClient to generate and add the interface name in the mechanism and mechanism preferences of the requests
func NewServer ¶
func NewServer(prefix string, generator NameGenerator) networkservice.NetworkServiceServer
NewServer implements NetworkServiceServer to generate and add the interface name in the mechanism and mechanism preferences of the requests
Note: NSM v1.1.1 kernel.NewServer() interferes with interfaceNameServer. It has been decided to let NSM name the NSE side interfaces if possible.
Types ¶
type CounterGenerator ¶ added in v0.7.0
type CounterGenerator struct {
// contains filtered or unexported fields
}
func (*CounterGenerator) Generate ¶ added in v0.7.0
func (cg *CounterGenerator) Generate(prefix string, maxLength int) string
TODO: make sure the generated name is within range (probably the prefix length should be limited as well)
func (*CounterGenerator) Release ¶ added in v0.7.0
func (cg *CounterGenerator) Release(name string)
type InterfaceNameChache ¶ added in v1.0.6
type InterfaceNameChache struct {
// contains filtered or unexported fields
}
InterfaceNameChache - InterfaceNameChache keeps track of interface names generated by NameGenerator and links them to IDs.
Uses a delayed release functionality, so that the same interface name could be recovered within release timeout for a particular ID. Thus avoiding interface name change upon NSM heal with reselect.
A particular interface name can be used by a single user.
func NewInterfaceNameChache ¶ added in v1.0.6
func NewInterfaceNameChache(ctx context.Context, generator NameGenerator, options ...Option) *InterfaceNameChache
InterfaceNameChache - Instantiates a new InterfaceNameChache.
func (*InterfaceNameChache) CheckAndReserve ¶ added in v1.0.12
func (inc *InterfaceNameChache) CheckAndReserve(id string, preferredName string, namePrefix string, maxLength int) string
CheckAndReserve - Checks if preferred interface name is already taken. If it is associated with a different id, then it can not be reserved. If free, reserves the name and stores it in the cache. If there's already a cached name for the id, it will keep the old cached one.
Returns preferredName or the name from cache, otherwise an empty string.
func (*InterfaceNameChache) Generate ¶ added in v1.0.6
func (inc *InterfaceNameChache) Generate(id string, namePrefix string, maxLength int) string
Generate - Returns interface name from cache if it already exists. Or generates a new one and stores it in the cache.
func (*InterfaceNameChache) Release ¶ added in v1.0.6
func (inc *InterfaceNameChache) Release(id string)
Release - Schedules delayed release of interface name associated with ID. Removal can be cancelled if re-added within the imeout.
type NameGenerator ¶
type Option ¶ added in v1.0.6
type Option func(*InterfaceNameChache)
Option is an option pattern for InterfaceNameChache
func WithReleaseTrigger ¶ added in v1.0.6
func WithReleaseTrigger(trigger ReleaseTrigger) Option
WithReleaseTrigger sets releaseTrigger for InterfaceNameChache
type RandomGenerator ¶
type RandomGenerator struct {
// contains filtered or unexported fields
}
func (*RandomGenerator) Generate ¶
func (rg *RandomGenerator) Generate(prefix string, maxLength int) string
TODO: make sure the generated name is within range (probably the prefix length should be limited as well)
func (*RandomGenerator) Release ¶ added in v0.7.0
func (rg *RandomGenerator) Release(name string)