sdk

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

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 Invoke added in v1.1.5

func Invoke(pluginName string, funcName string, params ...interface{}) (interface{}, error)

Invoke 触发指定plugin里的方法 example: Invoke("dog", "meow", repeat)

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 LoaderFunc

type LoaderFunc = func(ctx context.Context, key string, data []byte) error

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) GetMountDir

func (cc *PluginSpec) GetMountDir() string

all getter func

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 WithHotReload

func WithHotReload(v bool) PluginSpecOption

WithHotReload 允许热更新,开启watch目录

func WithInternalDir

func WithInternalDir(v string) PluginSpecOption

WithInternalDir service pod内部携带的plugin目录

func WithMountDir

func WithMountDir(v string) PluginSpecOption

WithMountDir 磁盘挂载目录

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) Debug

func (zl *ZapLogger) Debug(args ...any)

func (*ZapLogger) Debugf

func (zl *ZapLogger) Debugf(format string, args ...any)

func (*ZapLogger) Debugw

func (zl *ZapLogger) Debugw(msg string, keyVals ...any)

func (*ZapLogger) Error

func (zl *ZapLogger) Error(args ...any)

func (*ZapLogger) Errorf

func (zl *ZapLogger) Errorf(format string, args ...any)

func (*ZapLogger) Errorw

func (zl *ZapLogger) Errorw(msg string, keyVals ...any)

func (*ZapLogger) FlushLogger

func (zl *ZapLogger) FlushLogger() error

func (*ZapLogger) Info

func (zl *ZapLogger) Info(args ...any)

func (*ZapLogger) Infof

func (zl *ZapLogger) Infof(format string, args ...any)

func (*ZapLogger) Infow

func (zl *ZapLogger) Infow(msg string, keyVals ...any)

func (*ZapLogger) NewLoggerWith

func (zl *ZapLogger) NewLoggerWith(keyVals ...any) slog.Logger

func (*ZapLogger) Warn

func (zl *ZapLogger) Warn(args ...any)

func (*ZapLogger) Warnf

func (zl *ZapLogger) Warnf(format string, args ...any)

func (*ZapLogger) Warnw

func (zl *ZapLogger) Warnw(msg string, keyVals ...any)

func (*ZapLogger) Zap

func (zl *ZapLogger) Zap() *zap.SugaredLogger

Zap returns the internal zap.SugaredLogger to the caller.

Jump to

Keyboard shortcuts

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