plugins

package
v0.0.0-...-4384b37 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

README

插件开发指南

利用 go 包的 init 特性,将插件注册,并在主程序中调用。

添加插件

  1. 创建插件目录,并在插件目录中添加插件的文件
  2. 在plugins/README.md中添加插件的说明
  3. 需要实现插件的 init 函数,并在 init 函数中注册插件。
  4. 实现在 plugins 中 interface 的方法
  5. plugins/standard/imports.go 中添加插件的导入

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidConfig = errors.New("invalid config")
	ErrProtocol      = errors.New("protocol error")
)
View Source
var Plugins = make(map[string]PluginsCreator)

Functions

func MapToStruct

func MapToStruct(m map[string]string, s interface{}) error

func ParseInt

func ParseInt(s string, bitSize int) (int64, error)

func ParseInt64

func ParseInt64(s string) (int64, error)

func Register

func Register(name string, creator PluginsCreator)

Types

type Plugin

type Plugin interface {
	Name() string
	Description() string
	Init(config k8sq1comV1.Config) error
	Run() (int64, error)
}

func GetPlugin

func GetPlugin(name string) Plugin

type PluginsCreator

type PluginsCreator func() Plugin

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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