Documentation ¶
Index ¶
- func Extension() interface{}
- func GetManager() *hotswap.PluginManagerSwapper
- func GetPatchVersion() string
- func InstallPluginSpecWatchDog(dog func(cc *PluginSpec))
- func Invoke(pluginName string, funcName string, params ...interface{}) (interface{}, error)
- func InvokeEach(name string, params ...interface{})
- func MustInit(spec *PluginSpec)
- func PluginSpecOptionDeclareWithDefault() interface{}
- type LoaderFunc
- type PluginSpec
- func (cc *PluginSpec) ApplyOption(opts ...PluginSpecOption) []PluginSpecOption
- func (cc *PluginSpec) GetDirsToKeep() int
- func (cc *PluginSpec) GetExtensionNewer() func() interface{}
- func (cc *PluginSpec) GetFreeDelay() time.Duration
- func (cc *PluginSpec) GetHotReload() bool
- func (cc *PluginSpec) GetInternalDir() string
- func (cc *PluginSpec) GetMountDir() string
- func (cc *PluginSpec) GetOnFirstLoadData() interface{}
- func (cc *PluginSpec) GetOnReloadData() interface{}
- func (cc *PluginSpec) GetStaticPlugins() map[string]*hotswap.StaticPlugin
- type PluginSpecInterface
- type PluginSpecOption
- func WithDirsToKeep(v int) PluginSpecOption
- func WithExtensionNewer(v func() interface{}) PluginSpecOption
- func WithFreeDelay(v time.Duration) PluginSpecOption
- func WithHotReload(v bool) PluginSpecOption
- func WithInternalDir(v string) PluginSpecOption
- func WithMountDir(v string) PluginSpecOption
- func WithOnFirstLoadData(v interface{}) PluginSpecOption
- func WithOnReloadData(v interface{}) PluginSpecOption
- func WithStaticPlugins(v map[string]*hotswap.StaticPlugin) PluginSpecOption
- type PluginSpecVisitor
- type ZapLogger
- func (zl *ZapLogger) Debug(args ...any)
- func (zl *ZapLogger) Debugf(format string, args ...any)
- func (zl *ZapLogger) Debugw(msg string, keyVals ...any)
- func (zl *ZapLogger) Error(args ...any)
- func (zl *ZapLogger) Errorf(format string, args ...any)
- func (zl *ZapLogger) Errorw(msg string, keyVals ...any)
- func (zl *ZapLogger) FlushLogger() error
- func (zl *ZapLogger) Info(args ...any)
- func (zl *ZapLogger) Infof(format string, args ...any)
- func (zl *ZapLogger) Infow(msg string, keyVals ...any)
- func (zl *ZapLogger) NewLoggerWith(keyVals ...any) slog.Logger
- func (zl *ZapLogger) Warn(args ...any)
- func (zl *ZapLogger) Warnf(format string, args ...any)
- func (zl *ZapLogger) Warnw(msg string, keyVals ...any)
- func (zl *ZapLogger) Zap() *zap.SugaredLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Extension ¶ added in v1.1.5
func Extension() interface{}
Extension 返回 HotswapSpec.ExtensionNewer 里的方法 example: Extension().(*g.VaultExtension).Meow(repeat)
func GetManager ¶
func GetManager() *hotswap.PluginManagerSwapper
func GetPatchVersion ¶ added in v1.1.6
func GetPatchVersion() string
GetPatchVersion 获取当前加载的plugin版本信息 默认为空
func InstallPluginSpecWatchDog ¶
func InstallPluginSpecWatchDog(dog func(cc *PluginSpec))
InstallPluginSpecWatchDog the installed func will called when NewPluginSpec called
func InvokeEach ¶ added in v1.1.5
func InvokeEach(name string, params ...interface{})
InvokeEach 触发每个plugin里的name方法 example: InvokeEach("meow", repeat)
func MustInit ¶
func MustInit(spec *PluginSpec)
MustInit initializes the plugin manager. MountDir 是在pmt里设置的磁盘挂载目录, 只对k8s环境生效 如果不是k8s环境, 忽略mountDir, 使用相对路径 bin/plugin 加载plugin
func PluginSpecOptionDeclareWithDefault ¶
func PluginSpecOptionDeclareWithDefault() interface{}
Types ¶
type PluginSpec ¶
type PluginSpec struct { MountDir string `usage:"磁盘挂载目录"` // annotation@MountDir(comment="磁盘挂载目录") HotReload bool `usage:"允许热更新,开启watch目录"` // annotation@HotReload(comment="允许热更新,开启watch目录") DirsToKeep int `usage:"同一service, 磁盘保留发布的目录数。如果设为0,则不删除历史目录"` // annotation@DirsToKeep(comment="同一service, 磁盘保留发布的目录数。如果设为0,则不删除历史目录") InternalDir string `usage:"service pod内部携带的plugin目录"` // annotation@InternalDir(comment="service pod内部携带的plugin目录") OnFirstLoadData interface{} `usage:"第一次OnLoad的data参数"` // annotation@OnFirstLoadData(comment="第一次OnLoad的data参数") OnReloadData interface{} `usage:"热更时新插件OnLoad的data参数"` // annotation@OnReloadData(comment="热更时新插件OnLoad的data参数") 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.") 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]*hotswap.StaticPlugin `usage:"the static plugins for static linking. 宿主程序直接编译的插件 用做debug和windows"` // annotation@StaticPlugins(comment="the static plugins for static linking. 宿主程序直接编译的插件 用做debug和windows") }
PluginSpec should use NewPluginSpec to initialize it
func NewPluginSpec ¶
func NewPluginSpec(opts ...PluginSpecOption) *PluginSpec
NewPluginSpec new PluginSpec
func (*PluginSpec) ApplyOption ¶
func (cc *PluginSpec) ApplyOption(opts ...PluginSpecOption) []PluginSpecOption
ApplyOption apply multiple new option and return the old ones sample: old := cc.ApplyOption(WithTimeout(time.Second)) defer cc.ApplyOption(old...)
func (*PluginSpec) GetDirsToKeep ¶
func (cc *PluginSpec) GetDirsToKeep() int
func (*PluginSpec) GetExtensionNewer ¶ added in v1.1.5
func (cc *PluginSpec) GetExtensionNewer() func() interface{}
func (*PluginSpec) GetFreeDelay ¶ added in v1.1.5
func (cc *PluginSpec) GetFreeDelay() time.Duration
func (*PluginSpec) GetHotReload ¶
func (cc *PluginSpec) GetHotReload() bool
func (*PluginSpec) GetInternalDir ¶
func (cc *PluginSpec) GetInternalDir() string
func (*PluginSpec) GetOnFirstLoadData ¶ added in v1.1.5
func (cc *PluginSpec) GetOnFirstLoadData() interface{}
func (*PluginSpec) GetOnReloadData ¶ added in v1.1.5
func (cc *PluginSpec) GetOnReloadData() interface{}
func (*PluginSpec) GetStaticPlugins ¶ added in v1.1.5
func (cc *PluginSpec) GetStaticPlugins() map[string]*hotswap.StaticPlugin
type PluginSpecInterface ¶
type PluginSpecInterface interface { PluginSpecVisitor ApplyOption(...PluginSpecOption) []PluginSpecOption }
PluginSpecInterface visitor + ApplyOption interface for PluginSpec
type PluginSpecOption ¶
type PluginSpecOption func(cc *PluginSpec) PluginSpecOption
PluginSpecOption option func
func WithDirsToKeep ¶
func WithDirsToKeep(v int) PluginSpecOption
WithDirsToKeep 同一service, 磁盘保留发布的目录数。如果设为0,则不删除历史目录
func WithExtensionNewer ¶ added in v1.1.5
func WithExtensionNewer(v func() interface{}) PluginSpecOption
WithExtensionNewer the function used to create a new object for PluginManager.Vault.Extension.
func WithFreeDelay ¶ added in v1.1.5
func WithFreeDelay(v time.Duration) PluginSpecOption
WithFreeDelay the delay time of calling OnFree. The default value is 5 minutes.
func WithInternalDir ¶
func WithInternalDir(v string) PluginSpecOption
WithInternalDir service pod内部携带的plugin目录
func WithOnFirstLoadData ¶ added in v1.1.5
func WithOnFirstLoadData(v interface{}) PluginSpecOption
WithOnFirstLoadData 第一次OnLoad的data参数
func WithOnReloadData ¶ added in v1.1.5
func WithOnReloadData(v interface{}) PluginSpecOption
WithOnReloadData 热更时新插件OnLoad的data参数
func WithStaticPlugins ¶ added in v1.1.5
func WithStaticPlugins(v map[string]*hotswap.StaticPlugin) PluginSpecOption
WithStaticPlugins the static plugins for static linking. 宿主程序直接编译的插件 用做debug和windows
type PluginSpecVisitor ¶
type PluginSpecVisitor interface { GetMountDir() string GetHotReload() bool GetDirsToKeep() int GetInternalDir() string GetOnFirstLoadData() interface{} GetOnReloadData() interface{} GetFreeDelay() time.Duration GetExtensionNewer() func() interface{} GetStaticPlugins() map[string]*hotswap.StaticPlugin }
PluginSpecVisitor visitor interface for PluginSpec
type ZapLogger ¶
type ZapLogger struct {
// contains filtered or unexported fields
}
ZapLogger is a wrapper of zap.SugaredLogger.
func (*ZapLogger) FlushLogger ¶
func (*ZapLogger) Zap ¶
func (zl *ZapLogger) Zap() *zap.SugaredLogger
Zap returns the internal zap.SugaredLogger to the caller.