plugin

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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context interface {
	codec.Union
	Plugin() *Plugin // get self
	L() *Logger      // Log Service
}

type HandlerFunc

type HandlerFunc func(ctx Context) (interface{}, error)

type LogLevel

type LogLevel int32
const (
	LogLevelDebug LogLevel = 0
	LogLevelInfo  LogLevel = 1
	LogLevelWarn  LogLevel = 2
	LogLevelError LogLevel = 3
)

type Logger

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

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

func (*Logger) Debugf

func (l *Logger) Debugf(format string, v ...interface{})

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...interface{})

func (*Logger) Info

func (l *Logger) Info(v ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(format string, v ...interface{})

func (*Logger) Warn

func (l *Logger) Warn(v ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(format string, v ...interface{})

type Option

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

func WithCallOpts

func WithCallOpts(opts ...grpc.CallOption) Option

func WithDialOpts

func WithDialOpts(opts ...grpc.DialOption) Option

func WithHeartbeat

func WithHeartbeat(dur time.Duration) Option

WithHeartbeat set heartbeat, default is 10s

func WithLogLevel

func WithLogLevel(level LogLevel) Option

WithLogLevel set log level, default is Info

func WithOnPanic

func WithOnPanic(f func(plugin *Plugin, execID uint64, funcName string, err error)) Option

WithOnPanic default is Log.Errorf

type Options

type Options struct {
	DialOpts []grpc.DialOption
	CallOpts []grpc.CallOption

	Heartbeat time.Duration
	LogLevel  LogLevel
	OnPanic   func(plugin *Plugin, execID uint64, funcName string, err error)
}

type Plugin

type Plugin struct {
	Log *Logger
	// contains filtered or unexported fields
}

func New

func New(name, ver, token string, opts ...Option) *Plugin

func (*Plugin) Funcs

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

func (*Plugin) Handle

func (p *Plugin) Handle(funcName string, handler HandlerFunc)

func (*Plugin) Mount

func (p *Plugin) Mount(target string, port int) error

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Opts

func (p *Plugin) Opts() Options

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

func (*Plugin) Shutdown

func (p *Plugin) Shutdown(reason shared.UnbindReason, msg *string) []error

func (*Plugin) Status

func (p *Plugin) Status() Status

func (*Plugin) Token

func (p *Plugin) Token() string

func (*Plugin) Version

func (p *Plugin) Version() string

type Status

type Status int32
const (
	StatusConnected    Status = 0
	StatusDisconnected Status = 1
)

Jump to

Keyboard shortcuts

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