plugin

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EachMeta

func EachMeta(iter func(id string, meta map[string]interface{}))

EachMeta iterates over each ID and meta.

func Register

func Register(pin Plugin)

Register registers a new plugin. It will panic if multiple plugin are registered under the same ID.

Types

type Plugin

type Plugin interface {
	// IDs must be lowercase and only contain alphanumeric characters and hyphens.
	ID() string

	// Meta exposes plugin metadata as key-value pairs.
	// Commonly used keys are: "url" and "description".
	Meta() map[string]interface{}

	// Init callback is called on init.
	Init(*api.Routes) error

	// Close callback is called on shutdown.
	Close() error
}

A Plugin interface.

func New

func New(id string, meta map[string]interface{}, init func(*api.Routes) error, close func() error) Plugin

New inits a simple plugin.

type Set

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

Set contains the set of loaded plugins.

func Init

func Init(rts *api.Routes, enabled []string) (*Set, error)

Init initializes registered plugins.

func (*Set) Close

func (s *Set) Close() error

Close closes all plugins.

func (*Set) MarshalJSON

func (s *Set) MarshalJSON() ([]byte, error)

MarshalJSON encodes the set as JSON.

Jump to

Keyboard shortcuts

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