interfacename

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 15 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)

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.

func NewInterfaceNameChache added in v1.0.6

func NewInterfaceNameChache(ctx context.Context, generator NameGenerator, options ...Option) *InterfaceNameChache

InterfaceNameChache - Instantiates a new InterfaceNameChache.

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)
}

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)

type ReleaseTrigger added in v1.0.6

type ReleaseTrigger func() <-chan struct{}

Jump to

Keyboard shortcuts

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