plugin

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(typ interface{}) interface{}

func CreateCfg

func CreateCfg(typ interface{}) interface{}

func CreateWithCfg

func CreateWithCfg(typ interface{}, cfg interface{}) interface{}

创建一个注册的Plugin 这里不返回错误而是直接panic的原因是: Create函数只是把plugin创建出来,并把cfg设置到plugin中对应的一个字段里。 这里的panic分为两种情况 1. plugin不存在,说明没有注册,大部分情况是没有调用RegisterPlugin 2. cfg设置失败,说明plugin本身定义的有问题 这两种情况下说明代码本身有问题,所以直接panic.

func Register

func Register(typ interface{}, creator Creator)

推荐自定义plugin的类型,不要直接使用基础类型,例如 type DaemonType string const DaemonTypeHttpd DaemonType = "httpd" Register(DaemonTypeHttpd, func() interface{} { return NewHttpd() }).

func RegisterCfg

func RegisterCfg(typ interface{}, creator CfgCreator)

func RegisterWithCfg added in v0.6.4

func RegisterWithCfg(typ interface{}, creator Creator, cfgCreator CfgCreator)

func SetCfg

func SetCfg(p interface{}, cfg interface{})

Types

type CfgCreator

type CfgCreator func() interface{}

type CfgGetter

type CfgGetter interface {
	GetCfg() interface{}
}

type CfgSetter

type CfgSetter interface {
	SetCfg(cfg interface{})
}

type Creator

type Creator func() interface{}

type Plugin

type Plugin interface {
	CfgGetter
	Type() interface{}
}

type Type

type Type string

Jump to

Keyboard shortcuts

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