factory

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HandshakeConfig = go_plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "BASIC_PLUGIN",
	MagicCookieValue: "hello",
}

Functions

func BuildFrame added in v0.0.3

func BuildFrame(v *viper.Viper, info *BuildPluginInfo)

func BuildInitField

func BuildInitField(structName string) string

func BuildNewStruct

func BuildNewStruct(structName string, fields Fields,
	oldFields []db2entity.Field) string

func BuildPlugin

func BuildPlugin(dir string) error

func BuildPluginEnv

func BuildPluginEnv(info *BuildPluginInfo, buildBeforeFunc func()) error

@ 建立虚拟环境

func Clear

func Clear(info *BuildPluginInfo) error

func CopyFile

func CopyFile(dstName, srcName string, packageName string) (bool, error)

@ Copy File @ repackagename

func ExecPlugin

func ExecPlugin(v *viper.Viper, info *BuildPluginInfo) error

func ExtendField

func ExtendField(v *viper.Viper, info *BuildPluginInfo) bool

extend logger and conf

func GenPlugin

func GenPlugin(structName string, fields []db2entity.Field, dir string, oldImport []string) (string, error)

func GetNewStr

func GetNewStr(v *viper.Viper, info *BuildPluginInfo) string

func GetReturnStr

func GetReturnStr(info *BuildPluginInfo) string

func GetSortBody

func GetSortBody(structName string, fields []db2entity.Field) string

func HandelPlural

func HandelPlural(v *viper.Viper, info *BuildPluginInfo) bool

处理复数

func HandleInitFieldsAndPool

func HandleInitFieldsAndPool(v *viper.Viper, info *BuildPluginInfo) bool

初始化变量,生成临时对象池

func HandleModel

func HandleModel(v *viper.Viper) error

func HandleNewStruct

func HandleNewStruct(info *BuildPluginInfo, newStrcut string) bool

func HandlePluralPool

func HandlePluralPool(v *viper.Viper, info *BuildPluginInfo)

复数池

func HandlePool

func HandlePool(v *viper.Viper, info *BuildPluginInfo)

单数池

func HandleVar

func HandleVar(info *BuildPluginInfo, varName string, context *string) bool

func NewFrame

func NewFrame(v *viper.Viper, info *BuildPluginInfo) string

func NewOptionParam added in v0.0.4

func NewOptionParam(v *viper.Viper, info *BuildPluginInfo)

func NewVarStr

func NewVarStr(v *viper.Viper, info *BuildPluginInfo)

func ReWriteModelContent

func ReWriteModelContent(info *BuildPluginInfo) error

有扩展属性才重写

func ReplaceContent added in v0.0.3

func ReplaceContent(v *viper.Viper, info *BuildPluginInfo) (string, error)

Types

type BuildPluginInfo

type BuildPluginInfo struct {
	VarStr string

	InitField InitFieldsReturn

	NewStr string

	NewVarStr string

	OptionParam string
	// contains filtered or unexported fields
}

func FindModel

func FindModel(modelPath, modelName, modelNamePlural string) (*BuildPluginInfo, error)

@ 查找模型 @ 解析模型

type Field

type Field struct {
	Name     string `json:"Name"`
	Size     int    `json:"Size"`
	Type     string `json:"Type"`
	TypeName string `json:"TypeName"`
}

type Fields

type Fields []Field

type InitFieldsReturn

type InitFieldsReturn struct {
	Fields     []string `json:"fields"`
	SpecFields []Field  `json:"SpecFields"`
}

type Model

type Model interface {
	Sort() string

	InitField() string
}

Model is the interface that we're exposing as a plugin.

type ModelPlugin

type ModelPlugin struct {
	// Impl Injection
	Impl Model
}

This is the implementation of plugin.Plugin so we can serve/consume this

This has two methods: Server must return an RPC server for this plugin type. We construct a ModelRPCServer for this.

Client must return an implementation of our interface that communicates over an RPC client. We return ModelRPC for this.

Ignore MuxBroker. That is used to create more multiplexed streams on our plugin connection and is a more advanced use case.

func (ModelPlugin) Client

func (ModelPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*ModelPlugin) Server

func (p *ModelPlugin) Server(*plugin.MuxBroker) (interface{}, error)

type ModelRPC

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

Here is an implementation that talks over RPC

func (*ModelRPC) InitField

func (g *ModelRPC) InitField() string

func (*ModelRPC) Sort

func (g *ModelRPC) Sort() string

type ModelRPCServer

type ModelRPCServer struct {
	// This is the real implementation
	Impl Model
}

Here is the RPC server that ModelRPC talks to, conforming to the requirements of net/rpc

func (*ModelRPCServer) InitField

func (s *ModelRPCServer) InitField(args interface{}, resp *string) error

func (*ModelRPCServer) Sort

func (s *ModelRPCServer) Sort(args interface{}, resp *string) error

type SortReturn

type SortReturn struct {
	Fields Fields `json:"fields"`
	Size   int    `json:"size"`
}

type Var

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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