pkg

package
v0.0.0-...-46a8698 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooManyServers = errors.New("too many UDP servers configured")
)

Errors relating to loading and executing upon the plugin dynamic configs.

View Source
var RunBackgroundListener = sdk.PluginAction{
	Name: "run background JTI listener",
	Action: func(p *sdk.Plugin) error {

		serverConfig := config.Get()
		if serverConfig == nil {
			return errors.New("failed to load cached UDP server configuration")
		}

		deviceManager := manager.NewPluginDeviceManager(p)

		svr := protocol.NewJtiUDPServer(serverConfig, deviceManager)

		log.Info("[jti] starting UDP server listen")
		go func() {
			if err := svr.Listen(); err != nil {
				log.WithError(err).Error("[jti] failed UDP server listen")
				panic(err)
			}
			log.Info("[jti] finished UDP server listen")
		}()

		return nil
	},
}

RunBackgroundListener is a plugin pre-run action which starts the UDP server, listening for incoming streamed data from Juniper equipment.

Functions

func DeviceIdentifier

func DeviceIdentifier(data map[string]interface{}) string

DeviceIdentifier is the custom device identifier function for the JTI plugin.

Since all devices are created dynamically at runtime, we have some guarantees of what fields exist in the data field and how they are structured. The runtime device loader will always put all fields pertaining to the ID of the plugin into an map under the "id" key.

func LoadDynamicConfig

func LoadDynamicConfig(data map[string]interface{}) ([]*sdk.Device, error)

LoadDynamicConfig loads the dynamic configuration provided in the plugin config, creates the necessary data, and starts receiving data for the configured data sources.

func MakePlugin

func MakePlugin() (*sdk.Plugin, error)

MakePlugin creates a new instance of an SDK plugin and registers all of the Juniper JTI-specific capabilities with the plugin.

Types

This section is empty.

Jump to

Keyboard shortcuts

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