plugin

package
v0.0.0-...-a294835 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StartupEvent         = "startup"
	AdminAPIStartupEvent = "admin_startup"

	ReloadEvent   = "reload"
	ShutdownEvent = "shutdown"
	SetupEvent    = "setup"
)

Define the event names for the startup and shutdown events

Variables

This section is empty.

Functions

func Decode

func Decode(rawConfig map[string]interface{}, obj interface{}) error

Decode decodes a map string interface into a struct for some reasons mapstructure.Decode() gives empty arrays for all resulting config fields this is quick workaround hack t make it work FIXME: investigate and fix mapstructure.Decode() behaviour and remove this dirty hack

func EmitEvent

func EmitEvent(name string, event interface{}) error

EmitEvent executes the different hooks passing the EventType as an argument. This is a blocking function. Hook developers should use 'go' keyword if they don't want to block Janus.

func RegisterEventHook

func RegisterEventHook(name string, hook EventHook) error

RegisterEventHook plugs in hook. All the hooks should register themselves and they must have a name.

func RegisterPlugin

func RegisterPlugin(name string, plugin Plugin) error

RegisterPlugin plugs in plugin. All plugins should register themselves, even if they do not perform an action associated with a directive. It is important for the process to know which plugins are available.

The plugin MUST have a name: lower case and one word. If this plugin has an action, it must be the name of the directive that invokes it. A name is always required and must be unique for the server type.

func ValidateConfig

func ValidateConfig(name string, rawConfig Config) (bool, error)

ValidateConfig validates the plugin configuration data

Types

type Config

type Config map[string]interface{}

Config initialization options.

type EventHook

type EventHook func(event interface{}) error

EventHook is a type which holds information about a startup hook plugin.

type OnAdminAPIStartup

type OnAdminAPIStartup struct {
	Router router.Router
}

OnAdminAPIStartup represents a event that happens when Janus starts up the admin API

type OnReload

type OnReload struct {
	Configurations []*api.Definition
}

OnReload represents a event that happens when Janus hot reloads it's configurations

type OnStartup

type OnStartup struct {
	StatsClient   client.Client
	MongoDB       *mongo.Database
	Cassandra     wrapper.Holder
	Register      *proxy.Register
	Config        *config.Specification
	Configuration []*api.Definition
}

OnStartup represents a event that happens when Janus starts up on the main process

type Plugin

type Plugin struct {
	Action   SetupFunc
	Validate ValidateFunc
}

Plugin defines basic methods for plugins

type SetupFunc

type SetupFunc func(def *proxy.RouterDefinition, rawConfig Config) error

SetupFunc is used to set up a plugin, or in other words, execute a directive. It will be called once per key for each server block it appears in.

func DirectiveAction

func DirectiveAction(name string) (SetupFunc, error)

DirectiveAction gets the action for a plugin

type ValidateFunc

type ValidateFunc func(rawConfig Config) (bool, error)

ValidateFunc validates configuration data against the plugin struct

Directories

Path Synopsis
encrypt
Package encrypt is for hashing.
Package encrypt is for hashing.

Jump to

Keyboard shortcuts

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