plugin

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithContext

func WithContext(ctx context.Context, base PluginBase) context.Context

WithContext returns a new Context that carries value.

Types

type OptionFunc

type OptionFunc func(o *pluginOptions)

func Context

func Context(ctx context.Context) OptionFunc

Context with service context.

func ID

func ID(id string) OptionFunc

ID with service id.

func Metadata

func Metadata(md map[string]string) OptionFunc

Metadata with service metadata.

func Monitor

func Monitor(enable bool) OptionFunc

TODO Monitor未实现

func Name

func Name(name string) OptionFunc

Name with service name.

func RegistrarTimeout

func RegistrarTimeout(t time.Duration) OptionFunc

RegistrarTimeout with registrar timeout.

func Registrars

func Registrars(r register.Registrar) OptionFunc

Registrars with service registry.

func Signal

func Signal(sigs ...os.Signal) OptionFunc

Signal with exit signals.

func Version

func Version(version string) OptionFunc

Version with service version.

type PluginBase

type PluginBase interface {
	ID() string
	Name() string
	Version() string
	Metadata() map[string]string

	Add(items ...PluginItem)
	Run()
	Stop() error
	GetOpts() *pluginOptions
}

func NewBase

func NewBase(conf *gofkConfs.PluginConfig, opts ...OptionFunc) PluginBase

type PluginItem

type PluginItem interface {
	Start() error //开始插件
	Exit()        //退出插件
	Enable() bool //插件开关
	Name() string //服务名称
}

Jump to

Keyboard shortcuts

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