factory

package
v0.0.0-...-6d34543 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type EsimFactory

type EsimFactory struct {
	// struct name which be search
	StructName string

	// Struct will be create
	NewStructInfo *structInfo

	ReleaseStr string

	InitField *InitFieldsReturn

	NewPluralStr string

	ReleasePluralStr string

	TypePluralStr string

	// option start
	Option1 string

	Option2 string

	Option3 string

	Option4 string

	Option5 string

	OptionParam string

	WithNew bool

	SpecFieldInitStr string

	ReturnStr string

	StructTpl templates.StructInfo
	// contains filtered or unexported fields
}

+-----------+-----------+. | firstPart | package | | | import | | ----------| ----------| | secondPart| var | | | | | ----------| ----------| | thirdPart | struct | | | funcBody | | ----------| ----------|

func NewEsimFactory

func NewEsimFactory(options ...Option) *EsimFactory

func (*EsimFactory) Close

func (ef *EsimFactory) Close()

func (*EsimFactory) Run

func (ef *EsimFactory) Run(v *viper.Viper) error

type InitFieldsReturn

type InitFieldsReturn struct {
	Fields     []string    `json:"fields"`
	SpecFields []pkg.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 Option

type Option func(*EsimFactory)

func WithEsimFactoryLogger

func WithEsimFactoryLogger(logger log.Logger) Option

func WithEsimFactoryTpl

func WithEsimFactoryTpl(tpl templates.Tpl) Option

func WithEsimFactoryWriter

func WithEsimFactoryWriter(writer filedir.IfaceWriter) Option

type Plural

type Plural struct {
	PluralName string

	StructName string

	Star string
	// contains filtered or unexported fields
}

func NewPlural

func NewPlural() Plural

func (Plural) NewString

func (pl Plural) NewString() string

func (Plural) ReleaseString

func (pl Plural) ReleaseString() string

func (Plural) TypeString

func (pl Plural) TypeString() string

type PoolTpl

type PoolTpl struct {
	VarPoolName string

	StructName string
	// contains filtered or unexported fields
}

func NewPoolTpl

func NewPoolTpl() PoolTpl

func (PoolTpl) String

func (pt PoolTpl) String() string

type RPCPluginStructField

type RPCPluginStructField struct {
	StructName string

	StructFileName string

	StrcutInfo *structInfo

	Fields []pkg.Field
	// contains filtered or unexported fields
}

func NewRPCPluginStructField

func NewRPCPluginStructField(writer filedir.IfaceWriter,
	logger log.Logger) *RPCPluginStructField

func (*RPCPluginStructField) Close

func (rps *RPCPluginStructField) Close()

func (*RPCPluginStructField) GenInitFieldStr

func (rps *RPCPluginStructField) GenInitFieldStr(getType reflect.Type, fieldLink,
	initName string, specFilds *pkg.Fields) []string

func (*RPCPluginStructField) HandleField

func (rps *RPCPluginStructField) HandleField(fields []pkg.Field, data interface{})

func (*RPCPluginStructField) KindToInit

func (rps *RPCPluginStructField) KindToInit(refType reflect.Type) string

func (*RPCPluginStructField) SetFilesName

func (rps *RPCPluginStructField) SetFilesName(filesName []string)

func (*RPCPluginStructField) SetPackName

func (rps *RPCPluginStructField) SetPackName(packName string)

func (*RPCPluginStructField) SetStructDir

func (rps *RPCPluginStructField) SetStructDir(structDir string)

func (*RPCPluginStructField) SetStructFileName

func (rps *RPCPluginStructField) SetStructFileName(structFileName string)

func (*RPCPluginStructField) SetStructInfo

func (rps *RPCPluginStructField) SetStructInfo(s *structInfo)

func (*RPCPluginStructField) SetStructName

func (rps *RPCPluginStructField) SetStructName(structName string)

type SortReturn

type SortReturn struct {
	Fields pkg.Fields `json:"fields"`
}

type StructFieldIface

type StructFieldIface interface {
	HandleField(fields []pkg.Field, data interface{})

	Close()

	SetStructInfo(*structInfo)

	SetStructName(string)

	SetStructDir(string)

	SetStructFileName(string)

	SetFilesName(filesName []string)

	SetPackName(packName string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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