core

package
v0.0.0-...-bacbef4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Core

type Core struct {
	// contains filtered or unexported fields
}

func New

func New(token string, opts ...Option) *Core

func (*Core) Call

func (c *Core) Call(plugin, version, funcName string, args interface{}) (Result, error)

Call blocks until the func is executed or timeout

args can be map[string]interface{} or []byte

func (*Core) Opts

func (c *Core) Opts() Options

Opts returns the options of the core,it's read-only

func (*Core) Plugin

func (c *Core) Plugin(name, version string) (*PluginInfo, bool)

Plugin returns the plugin info of the specified plugin

func (*Core) Plugins

func (c *Core) Plugins() []*PluginInfo

Plugins returns the plugin info of all plugins

func (*Core) Serve

func (c *Core) Serve() error

func (*Core) Shutdown

func (c *Core) Shutdown()

Shutdown core

func (*Core) ShutdownPlugin

func (c *Core) ShutdownPlugin(plugin, version string) error

func (*Core) Status

func (c *Core) Status() Status

func (*Core) Token

func (c *Core) Token() string

type DefaultHook

type DefaultHook struct {
	// contains filtered or unexported fields
}

func (*DefaultHook) OnExecReq

func (d *DefaultHook) OnExecReq(c *Core, p *PluginInfo, id uint64, funcName string, args interface{})

func (*DefaultHook) OnExecResp

func (d *DefaultHook) OnExecResp(c *Core, p *PluginInfo, id uint64, t shared.CodecType, result interface{}, err error)

func (*DefaultHook) OnPluginLog

func (d *DefaultHook) OnPluginLog(c *Core, p *PluginInfo, level shared.LogLevel, msg string)

func (*DefaultHook) OnPluginMount

func (d *DefaultHook) OnPluginMount(_ *Core, p *PluginInfo)

func (*DefaultHook) OnPluginPing

func (d *DefaultHook) OnPluginPing(c *Core, p *PluginInfo)

func (*DefaultHook) OnPluginUnmount

func (d *DefaultHook) OnPluginUnmount(c *Core, p *PluginInfo, reason shared.UnbindReason, msg *string)

type EmptyHook

type EmptyHook struct{}

func (EmptyHook) OnExecReq

func (e EmptyHook) OnExecReq(_ *Core, _ *PluginInfo, _ uint64, _ string, _ interface{})

func (EmptyHook) OnExecResp

func (e EmptyHook) OnExecResp(_ *Core, _ *PluginInfo, _ uint64, _ shared.CodecType, _ interface{}, _ error)

func (EmptyHook) OnPluginLog

func (e EmptyHook) OnPluginLog(_ *Core, _ *PluginInfo, _ shared.LogLevel, _ string)

func (EmptyHook) OnPluginMount

func (e EmptyHook) OnPluginMount(_ *Core, _ *PluginInfo)

func (EmptyHook) OnPluginPing

func (e EmptyHook) OnPluginPing(_ *Core, _ *PluginInfo)

func (EmptyHook) OnPluginUnmount

func (e EmptyHook) OnPluginUnmount(_ *Core, _ *PluginInfo, _ shared.UnbindReason, _ *string)

type Hook

type Hook interface {
	OnPluginMount(c *Core, p *PluginInfo)
	OnPluginUnmount(c *Core, p *PluginInfo, reason shared.UnbindReason, msg *string) // msg is optional
	OnPluginPing(c *Core, p *PluginInfo)
	OnPluginLog(c *Core, p *PluginInfo, level shared.LogLevel, msg string)
	OnExecReq(c *Core, p *PluginInfo, id uint64, funcName string, args interface{})                  // args might be []byte or map[string]interface{}
	OnExecResp(c *Core, p *PluginInfo, id uint64, t shared.CodecType, result interface{}, err error) // result might be []byte or map[string]interface{}

}

type Interface

type Interface map[string][]string

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithExecReqChSize

func WithExecReqChSize(size int) Option

WithExecReqChSize set the chan size, default is 0

func WithExecTimeout

func WithExecTimeout(dur time.Duration) Option

WithExecTimeout set the exec timeout, default is 10s

func WithHealthTimeout

func WithHealthTimeout(dur time.Duration) Option

WithHealthTimeout set the HealthTimeout, default is 15s

plugins with intervals higher than this limit will be disconnected and removed

func WithHooks

func WithHooks(h Hook) Option

func WithInterfaces

func WithInterfaces(interfaces ...Interface) Option

func WithLogLevel

func WithLogLevel(level shared.LogLevel) Option

WithLogLevel set the log level, default is Info

func WithPort

func WithPort(port int) Option

WithPort set the port, default is 13000

func WithServerOpts

func WithServerOpts(opts ...grpc.ServerOption) Option

type Options

type Options struct {
	Port          int
	HealthTimeout time.Duration
	ExecReqChSize int
	ExecTimeout   time.Duration
	// contains filtered or unexported fields
}

type PluginInfo

type PluginInfo struct {
	// contains filtered or unexported fields
}

func (*PluginInfo) Funcs

func (p *PluginInfo) Funcs() []string

func (*PluginInfo) Interface

func (p *PluginInfo) Interface() string

Interface implemented by plugin

func (*PluginInfo) Name

func (p *PluginInfo) Name() string

Name of plugin

func (*PluginInfo) Version

func (p *PluginInfo) Version() string

Version of plugin

type Result

type Result interface {
	codec.Union
}

type Status

type Status int32
const (
	StatusLaunched Status = 0
	StatusStopped  Status = 1
)

Jump to

Keyboard shortcuts

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