interfacename

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 16 Imported by: 1

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

View Source
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)

func (*CounterGenerator) Reserve added in v1.0.12

func (cg *CounterGenerator) Reserve(name, prefix string, maxLength int) error

Reserve - Reverse tries to reserve a certain name if the format is right

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 NameGenerator interface {
	Generate(prefix string, maxLength int) string
	Release(name string)
	Reserve(name, prefix string, maxLength int) error
}

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)

func (*RandomGenerator) Reserve added in v1.0.12

func (rg *RandomGenerator) Reserve(name, prefix string, maxLength int) error

Reserve - Reverse tries to reserve a certain name if the format is right

type ReleaseTrigger added in v1.0.6

type ReleaseTrigger func(ctx context.Context) <-chan struct{}

Jump to

Keyboard shortcuts

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