plugin

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: AGPL-3.0 Imports: 22 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultMinPort      uint   = 50000
	DefaultMaxPort      uint   = 60000
	PluginPriorityStart uint   = 1000
	EmptyPoolCapacity   int    = 0
	LoggerName          string = "plugin"
)

Variables

This section is empty.

Functions

func Verify added in v0.0.8

func Verify(params, returnVal *structpb.Struct) bool

Verify compares two structs and returns true if they are equal.

Types

type HookConfig added in v0.0.8

type HookConfig struct {
	Logger       zerolog.Logger
	Verification Policy
	// contains filtered or unexported fields
}

func NewHookConfig added in v0.0.8

func NewHookConfig() *HookConfig

func (*HookConfig) Add added in v0.0.8

func (h *HookConfig) Add(hookType HookType, prio Priority, hook HookDef)

func (*HookConfig) Get added in v0.0.8

func (h *HookConfig) Get(hookType HookType) map[Priority]HookDef

func (*HookConfig) Hooks added in v0.0.8

func (h *HookConfig) Hooks() map[HookType]map[Priority]HookDef

func (*HookConfig) Run added in v0.0.8

func (h *HookConfig) Run(
	ctx context.Context,
	args map[string]interface{},
	hookType HookType,
	verification Policy,
	opts ...grpc.CallOption,
) (map[string]interface{}, *gerr.GatewayDError)

type HookDef added in v0.0.8

type HookType added in v0.0.8

type HookType string
const (
	// Run command hooks (cmd/run.go).
	OnConfigLoaded HookType = "onConfigLoaded"
	OnNewLogger    HookType = "onNewLogger"
	OnNewPool      HookType = "onNewPool"
	OnNewProxy     HookType = "onNewProxy"
	OnNewServer    HookType = "onNewServer"
	OnSignal       HookType = "onSignal"
	// Server hooks (network/server.go).
	OnRun            HookType = "onRun"
	OnBooting        HookType = "onBooting"
	OnBooted         HookType = "onBooted"
	OnOpening        HookType = "onOpening"
	OnOpened         HookType = "onOpened"
	OnClosing        HookType = "onClosing"
	OnClosed         HookType = "onClosed"
	OnTraffic        HookType = "onTraffic"
	OnIngressTraffic HookType = "onIngressTraffic"
	OnEgressTraffic  HookType = "onEgressTraffic"
	OnShutdown       HookType = "onShutdown"
	OnTick           HookType = "onTick"
	// Pool hooks (network/pool.go).
	OnNewClient HookType = "onNewClient"
)

type Identifier added in v0.0.8

type Identifier struct {
	Name      string
	Version   string
	RemoteURL string
	Checksum  string
}

type Impl added in v0.0.8

type Impl struct {
	goplugin.NetRPCUnsupportedPlugin
	pluginV1.GatewayDPluginServiceServer

	ID          Identifier
	Description string
	Authors     []string
	License     string
	ProjectURL  string
	LocalPath   string
	Enabled     bool
	// internal and external config options
	Config map[string]string
	// hooks it attaches to
	Hooks    []HookType
	Priority Priority
	// required plugins to be loaded before this one
	// Built-in plugins are always loaded first
	Requires   []Identifier
	Tags       []string
	Categories []string
	// contains filtered or unexported fields
}

func (*Impl) Dispense added in v0.0.8

func (*Impl) Start added in v0.0.8

func (p *Impl) Start() (net.Addr, error)

func (*Impl) Stop added in v0.0.8

func (p *Impl) Stop()

type Plugin added in v0.0.8

type Plugin interface {
	Start() (net.Addr, error)
	Stop()
	Dispense() (pluginV1.GatewayDPluginServiceClient, *gerr.GatewayDError)
}

type Policy added in v0.0.8

type Policy int
const (
	// Non-strict (permissive) mode.
	PassDown Policy = iota // Pass down the extra keys/values in result to the next plugins
	// Strict mode.
	Ignore // Ignore errors and continue
	Abort  // Abort on first error and return results
	Remove // Remove the hook from the list on error and continue
)

type Priority added in v0.0.8

type Priority uint

Priority is the priority of a hook. Smaller values are executed first (higher priority).

type Registry added in v0.0.8

type Registry interface {
	Add(plugin *Impl) bool
	Get(id Identifier) *Impl
	List() []Identifier
	Remove(id Identifier)
	Shutdown()
	LoadPlugins(pluginConfig *koanf.Koanf)
	RegisterHooks(id Identifier)
}

type RegistryImpl added in v0.0.8

type RegistryImpl struct {
	// contains filtered or unexported fields
}

func NewRegistry added in v0.0.8

func NewRegistry(hooksConfig *HookConfig) *RegistryImpl

func (*RegistryImpl) Add added in v0.0.8

func (reg *RegistryImpl) Add(plugin *Impl) bool

func (*RegistryImpl) Get added in v0.0.8

func (reg *RegistryImpl) Get(id Identifier) *Impl

func (*RegistryImpl) List added in v0.0.8

func (reg *RegistryImpl) List() []Identifier

func (*RegistryImpl) LoadPlugins added in v0.0.8

func (reg *RegistryImpl) LoadPlugins(pluginConfig *koanf.Koanf)

func (*RegistryImpl) RegisterHooks added in v0.0.8

func (reg *RegistryImpl) RegisterHooks(id Identifier)

func (*RegistryImpl) Remove added in v0.0.8

func (reg *RegistryImpl) Remove(id Identifier)

func (*RegistryImpl) Shutdown added in v0.0.8

func (reg *RegistryImpl) Shutdown()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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