ifplugin

package
v3.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPlugin = *NewPlugin()

DefaultPlugin is a default instance of IfPlugin.

Functions

This section is empty.

Types

type API

type API interface {
	// GetInterfaceIndex gives read-only access to map with metadata of all configured
	// mock interfaces.
	GetInterfaceIndex() idxvpp.NameToIndex
}

API defines methods exposed by mock ifplugin.

type Deps

type Deps struct {
	infra.PluginDeps

	// the plugin depends on KVScheduler because it needs to register the
	// descriptor for interfaces.
	KVScheduler kvs.KVScheduler
}

Deps lists dependencies of the mock interface plugin.

type IfPlugin

type IfPlugin struct {
	Deps
	// contains filtered or unexported fields
}

IfPlugin configures mock interfaces.

func NewPlugin

func NewPlugin(opts ...Option) *IfPlugin

NewPlugin creates a new Plugin with the provides Options

func (*IfPlugin) Close

func (p *IfPlugin) Close() error

Close of a real (not-mock) plugin usually:

  • stops all the associated go routines (if any)
  • closes channels, registrations, etc..

In this example we do nothing (no need to un-register descriptor).

func (*IfPlugin) GetInterfaceIndex

func (p *IfPlugin) GetInterfaceIndex() idxvpp.NameToIndex

GetInterfaceIndex gives read-only access to map with metadata of all configured mock interfaces.

func (*IfPlugin) Init

func (p *IfPlugin) Init() error

Init of a real (not-mock) plugin usually:

  • loads configuration from a file (if any)
  • registers descriptors for all objects the plugin implements
  • potentially starts go routine to watch for some asynchronous events (from which usually sends notifications to KVScheduler via PushSBNotification)
  • etc.

In this mock ifplugin, we only only create mock SB handlers and register the descriptor.

type Option

type Option func(*IfPlugin)

Option is a function that can be used in NewPlugin to customize Plugin.

func UseDeps

func UseDeps(f func(*Deps)) Option

UseDeps returns Option that can inject custom dependencies.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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