Version: v0.0.20 Latest Latest

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

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 10 Imported by: 0




View Source
const Name = "plugin"


This section is empty.


func All

func All() map[string][]Plugin

func IsRegistered

func IsRegistered(plugin Plugin, opts ...ManagerOpt) bool

IsRegistered check plugin whether registered global. Notice plugin is not check whether is nil

func Register

func Register(plugin Plugin, opts ...ManagerOpt)

func String

func String() string


type Base

type Base struct {
	Name       string
	OnInit     func(ent interface{})
	OnWatch    func(name string, resp *watcher.Response)
	OnCommands func(cmd *cobra.Command)
	OnFlags    func(flags *pflag.FlagSet)

func (*Base) Commands

func (p *Base) Commands() *cobra.Command

func (*Base) Flags

func (p *Base) Flags() *pflag.FlagSet

func (*Base) Init

func (p *Base) Init(ent interface{}) (err error)

func (*Base) String

func (p *Base) String() string

func (*Base) Watch

func (p *Base) Watch(name string, r *watcher.Response) (err error)

type Manager

type Manager interface {
	Plugins(...ManagerOpt) []Plugin
	Register(Plugin, ...ManagerOpt)

func NewManager

func NewManager() Manager

NewManager creates a new internal_plugin manager

type ManagerOpt

type ManagerOpt func(o *ManagerOpts)

func Module

func Module(m string) ManagerOpt

Module will scope the plugin to a specific module, e.g. the "api"

type ManagerOpts

type ManagerOpts struct {
	Module string

type Option

type Option func(o *Options)

type Options

type Options struct {
	Name     string
	Flags    *pflag.FlagSet
	Commands *cobra.Command

type Plugin

type Plugin interface {
	Watch(name string, r *watcher.Response) error
	Init(ent interface{}) error
	Flags() *pflag.FlagSet
	Commands() *cobra.Command
	String() string

func List

func List(opts ...ManagerOpt) []Plugin

Jump to

Keyboard shortcuts

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