Documentation
¶
Index ¶
- Variables
- func InstallSpecWatchDog(dog func(cc *Spec))
- func SpecOptionDeclareWithDefault() interface{}
- type Details
- type Plugin
- type PluginFuncs
- type PluginManager
- type PluginManagerSwapper
- func (sw *PluginManagerSwapper) Current() *PluginManager
- func (sw *PluginManagerSwapper) LoadPlugins(data interface{}) (Details, error)
- func (sw *PluginManagerSwapper) Reload(data interface{}) (Details, error)
- func (sw *PluginManagerSwapper) ReloadCounter() int64
- func (sw *PluginManagerSwapper) ReloadWithCallback(data interface{}, extra ReloadCallback) (Details, error)
- func (sw *PluginManagerSwapper) ResetPluginDir(pluginDir string)
- func (sw *PluginManagerSwapper) StaticLinkingMode() bool
- type ReloadCallback
- type Spec
- func (cc *Spec) ApplyOption(opts ...SpecOption) []SpecOption
- func (cc *Spec) GetExtensionNewer() func() interface{}
- func (cc *Spec) GetFreeDelay() time.Duration
- func (cc *Spec) GetLogger() slog.Logger
- func (cc *Spec) GetReloadCallback() ReloadCallback
- func (cc *Spec) GetStaticPlugins() map[string]*StaticPlugin
- func (cc *Spec) GetWhitelist() []string
- type SpecInterface
- type SpecOption
- func WithExtensionNewer(v func() interface{}) SpecOption
- func WithFreeDelay(v time.Duration) SpecOption
- func WithLogger(v slog.Logger) SpecOption
- func WithReloadCallback(v ReloadCallback) SpecOption
- func WithStaticPlugins(v map[string]*StaticPlugin) SpecOption
- func WithWhitelist(v ...string) SpecOption
- type SpecVisitor
- type StaticPlugin
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotExist = errors.New("symbol does not exist")
)
Functions ¶
func InstallSpecWatchDog ¶ added in v1.1.5
func InstallSpecWatchDog(dog func(cc *Spec))
InstallSpecWatchDog the installed func will called when NewSpec called
func SpecOptionDeclareWithDefault ¶ added in v1.1.5
func SpecOptionDeclareWithDefault() interface{}
Types ¶
type Plugin ¶
type PluginFuncs ¶
type PluginFuncs struct { InvokeFunc func(name string, params ...interface{}) (interface{}, error) // contains filtered or unexported fields }
func NewPluginFuncs ¶
func NewPluginFuncs( fExport func() interface{}, hotswapLiveFuncs func() map[string]interface{}, hotswapLiveTypes func() map[string]func() interface{}, fImport func() interface{}, InvokeFunc func(name string, params ...interface{}) (interface{}, error), fOnFree func(), fOnInit func(sharedVault *vault.Vault) error, fOnLoad func(data interface{}) error, fReloadable func() bool, ) PluginFuncs
type PluginManager ¶
func (*PluginManager) FindPlugin ¶
func (pm *PluginManager) FindPlugin(name string) *Plugin
func (*PluginManager) InvokeEach ¶
func (pm *PluginManager) InvokeEach(name string, params ...interface{})
func (*PluginManager) InvokeEachBackward ¶
func (pm *PluginManager) InvokeEachBackward(name string, params ...interface{})
func (*PluginManager) Plugins ¶
func (pm *PluginManager) Plugins() []*Plugin
type PluginManagerSwapper ¶
func NewPluginManagerSwapper ¶
func NewPluginManagerSwapper(pluginDir string, opts ...SpecOption) *PluginManagerSwapper
func (*PluginManagerSwapper) Current ¶
func (sw *PluginManagerSwapper) Current() *PluginManager
func (*PluginManagerSwapper) LoadPlugins ¶
func (sw *PluginManagerSwapper) LoadPlugins(data interface{}) (Details, error)
func (*PluginManagerSwapper) Reload ¶
func (sw *PluginManagerSwapper) Reload(data interface{}) (Details, error)
func (*PluginManagerSwapper) ReloadCounter ¶
func (sw *PluginManagerSwapper) ReloadCounter() int64
func (*PluginManagerSwapper) ReloadWithCallback ¶
func (sw *PluginManagerSwapper) ReloadWithCallback(data interface{}, extra ReloadCallback) (Details, error)
func (*PluginManagerSwapper) ResetPluginDir ¶
func (sw *PluginManagerSwapper) ResetPluginDir(pluginDir string)
func (*PluginManagerSwapper) StaticLinkingMode ¶
func (sw *PluginManagerSwapper) StaticLinkingMode() bool
type ReloadCallback ¶
type ReloadCallback func(newManager, oldManager *PluginManager) error
type Spec ¶ added in v1.1.5
type Spec struct { Logger slog.Logger `usage:"replaces the default logger with your own."` // annotation@Logger(comment="replaces the default logger with your own.") FreeDelay time.Duration `usage:"the delay time of calling OnFree. The default value is 5 minutes."` // annotation@FreeDelay(comment="the delay time of calling OnFree. The default value is 5 minutes.") ReloadCallback ReloadCallback `usage:"the callback function of reloading."` // annotation@ReloadCallback(comment="the callback function of reloading.") ExtensionNewer func() interface{} `usage:"the function used to create a new object for PluginManager.Vault.Extension."` // annotation@ExtensionNewer(comment="the function used to create a new object for PluginManager.Vault.Extension.") StaticPlugins map[string]*StaticPlugin `usage:"the static plugins for static linking. 宿主程序直接编译的插件 用做debug和windows"` // annotation@StaticPlugins(comment="the static plugins for static linking. 宿主程序直接编译的插件 用做debug和windows") Whitelist []string `usage:"the plugins to load explicitly 若不为空 只加载白名单里的插件"` // annotation@Whitelist(comment="the plugins to load explicitly 若不为空 只加载白名单里的插件") }
Spec should use NewSpec to initialize it
func (*Spec) ApplyOption ¶ added in v1.1.5
func (cc *Spec) ApplyOption(opts ...SpecOption) []SpecOption
ApplyOption apply multiple new option and return the old ones sample: old := cc.ApplyOption(WithTimeout(time.Second)) defer cc.ApplyOption(old...)
func (*Spec) GetExtensionNewer ¶ added in v1.1.5
func (cc *Spec) GetExtensionNewer() func() interface{}
func (*Spec) GetFreeDelay ¶ added in v1.1.5
func (*Spec) GetReloadCallback ¶ added in v1.1.5
func (cc *Spec) GetReloadCallback() ReloadCallback
func (*Spec) GetStaticPlugins ¶ added in v1.1.5
func (cc *Spec) GetStaticPlugins() map[string]*StaticPlugin
func (*Spec) GetWhitelist ¶ added in v1.1.5
type SpecInterface ¶ added in v1.1.5
type SpecInterface interface { SpecVisitor ApplyOption(...SpecOption) []SpecOption }
SpecInterface visitor + ApplyOption interface for Spec
type SpecOption ¶ added in v1.1.5
type SpecOption func(cc *Spec) SpecOption
SpecOption option func
func WithExtensionNewer ¶
func WithExtensionNewer(v func() interface{}) SpecOption
WithExtensionNewer the function used to create a new object for PluginManager.Vault.Extension.
func WithFreeDelay ¶
func WithFreeDelay(v time.Duration) SpecOption
WithFreeDelay the delay time of calling OnFree. The default value is 5 minutes.
func WithLogger ¶
func WithLogger(v slog.Logger) SpecOption
WithLogger replaces the default logger with your own.
func WithReloadCallback ¶
func WithReloadCallback(v ReloadCallback) SpecOption
WithReloadCallback the callback function of reloading.
func WithStaticPlugins ¶
func WithStaticPlugins(v map[string]*StaticPlugin) SpecOption
WithStaticPlugins the static plugins for static linking. 宿主程序直接编译的插件 用做debug和windows
func WithWhitelist ¶
func WithWhitelist(v ...string) SpecOption
WithWhitelist the plugins to load explicitly 若不为空 只加载白名单里的插件
type SpecVisitor ¶ added in v1.1.5
type SpecVisitor interface { GetLogger() slog.Logger GetFreeDelay() time.Duration GetReloadCallback() ReloadCallback GetExtensionNewer() func() interface{} GetStaticPlugins() map[string]*StaticPlugin GetWhitelist() []string }
SpecVisitor visitor interface for Spec
type StaticPlugin ¶
type StaticPlugin struct { Name string PluginFuncs }