plugin

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: Apache-2.0 Imports: 9 Imported by: 36

Documentation

Index

Constants

View Source
const InsertionPointFormat = "@@thriftgo_insertion_point(%s)"

InsertionPointFormat is the format for insertion points.

Variables

View Source
var Generated_InsertionPoint_DEFAULT string
View Source
var Generated_Name_DEFAULT string
View Source
var MaxExecutionTime = time.Minute

MaxExecutionTime is a timeout for executing external plugins.

View Source
var Request_AST_DEFAULT *parser.Thrift
View Source
var Response_Contents_DEFAULT []*Generated
View Source
var Response_Error_DEFAULT string
View Source
var Response_Warnings_DEFAULT []string

Functions

func InsertionPoint

func InsertionPoint(names ...string) string

InsertionPoint returns a new insertion point.

func Marshal

func Marshal(data Writer) ([]byte, error)

Marshal serializes the data with binary protocol.

func MarshalRequest

func MarshalRequest(data *Request) ([]byte, error)

MarshalRequest .

func MarshalResponse

func MarshalResponse(data *Response) ([]byte, error)

MarshalResponse .

func Pack

func Pack(opts []Option) (ss []string)

Pack packs Option into strings.

func Unmarshal

func Unmarshal(data Reader, bs []byte) error

Unmarshal deserializes the data from bytes with binary protocol.

Types

type Desc

type Desc struct {
	Name    string
	Options []Option
}

Desc can be used to describes the interface of a plugin or a generator backend.

func ParseCompactArguments

func ParseCompactArguments(str string) (*Desc, error)

ParseCompactArguments parses a compact form option into arguments. A compact form option is like:

name:key1=val1,key2,key3=val3

This function barely checks the validity of the string, so the user should always provide a valid input.

type Generated

type Generated struct {
	Content        string  `thrift:"Content,1,required" db:"Content" json:"Content"`
	Name           *string `thrift:"Name,2" db:"Name" json:"Name,omitempty"`
	InsertionPoint *string `thrift:"InsertionPoint,3" db:"InsertionPoint" json:"InsertionPoint,omitempty"`
}

Attributes:

  • Content
  • Name
  • InsertionPoint

func NewGenerated

func NewGenerated() *Generated

func (*Generated) GetContent

func (p *Generated) GetContent() string

func (*Generated) GetInsertionPoint

func (p *Generated) GetInsertionPoint() string

func (*Generated) GetName

func (p *Generated) GetName() string

func (*Generated) IsSetInsertionPoint

func (p *Generated) IsSetInsertionPoint() bool

func (*Generated) IsSetName

func (p *Generated) IsSetName() bool

func (*Generated) Read

func (p *Generated) Read(iprot thrift.TProtocol) error

func (*Generated) ReadField1

func (p *Generated) ReadField1(iprot thrift.TProtocol) error

func (*Generated) ReadField2

func (p *Generated) ReadField2(iprot thrift.TProtocol) error

func (*Generated) ReadField3

func (p *Generated) ReadField3(iprot thrift.TProtocol) error

func (*Generated) String

func (p *Generated) String() string

func (*Generated) Write

func (p *Generated) Write(oprot thrift.TProtocol) error

type Option

type Option struct {
	Name string
	Desc string
}

Option is used to describes an option for a plugin or a generator backend.

type Plugin

type Plugin interface {
	// Name returns the name of the plugin.
	Name() string

	// Execute invokes the plugin and waits for response.
	Execute(req *Request) (res *Response)
}

Plugin .

func Lookup

func Lookup(arg string) (Plugin, error)

Lookup searches for PATH to find a plugin that match the description.

type Reader

type Reader interface {
	Read(iprot thrift.TProtocol) error
}

Reader reads data from an input thrift.TProtocol.

type Request

type Request struct {
	Version             string         `thrift:"Version,1,required" db:"Version" json:"Version"`
	GeneratorParameters []string       `thrift:"GeneratorParameters,2,required" db:"GeneratorParameters" json:"GeneratorParameters"`
	PluginParameters    []string       `thrift:"PluginParameters,3,required" db:"PluginParameters" json:"PluginParameters"`
	Language            string         `thrift:"Language,4,required" db:"Language" json:"Language"`
	OutputPath          string         `thrift:"OutputPath,5,required" db:"OutputPath" json:"OutputPath"`
	Recursive           bool           `thrift:"Recursive,6,required" db:"Recursive" json:"Recursive"`
	AST                 *parser.Thrift `thrift:"AST,7,required" db:"AST" json:"AST"`
}

Attributes:

  • Version
  • GeneratorParameters
  • PluginParameters
  • Language
  • OutputPath
  • Recursive
  • AST

func NewRequest

func NewRequest() *Request

func UnmarshalRequest

func UnmarshalRequest(bs []byte) (*Request, error)

UnmarshalRequest .

func (*Request) GetAST

func (p *Request) GetAST() *parser.Thrift

func (*Request) GetGeneratorParameters

func (p *Request) GetGeneratorParameters() []string

func (*Request) GetLanguage

func (p *Request) GetLanguage() string

func (*Request) GetOutputPath

func (p *Request) GetOutputPath() string

func (*Request) GetPluginParameters

func (p *Request) GetPluginParameters() []string

func (*Request) GetRecursive

func (p *Request) GetRecursive() bool

func (*Request) GetVersion

func (p *Request) GetVersion() string

func (*Request) IsSetAST

func (p *Request) IsSetAST() bool

func (*Request) Read

func (p *Request) Read(iprot thrift.TProtocol) error

func (*Request) ReadField1

func (p *Request) ReadField1(iprot thrift.TProtocol) error

func (*Request) ReadField2

func (p *Request) ReadField2(iprot thrift.TProtocol) error

func (*Request) ReadField3

func (p *Request) ReadField3(iprot thrift.TProtocol) error

func (*Request) ReadField4

func (p *Request) ReadField4(iprot thrift.TProtocol) error

func (*Request) ReadField5

func (p *Request) ReadField5(iprot thrift.TProtocol) error

func (*Request) ReadField6

func (p *Request) ReadField6(iprot thrift.TProtocol) error

func (*Request) ReadField7

func (p *Request) ReadField7(iprot thrift.TProtocol) error

func (*Request) String

func (p *Request) String() string

func (*Request) Write

func (p *Request) Write(oprot thrift.TProtocol) error

type Response

type Response struct {
	Error    *string      `thrift:"Error,1" db:"Error" json:"Error,omitempty"`
	Contents []*Generated `thrift:"Contents,2" db:"Contents" json:"Contents,omitempty"`
	Warnings []string     `thrift:"Warnings,3" db:"Warnings" json:"Warnings,omitempty"`
}

Attributes:

  • Error
  • Contents
  • Warnings

func BuildErrorResponse

func BuildErrorResponse(errMsg string, warnings ...string) *Response

BuildErrorResponse creates a plugin response with a error message.

func NewResponse

func NewResponse() *Response

func UnmarshalResponse

func UnmarshalResponse(bs []byte) (*Response, error)

UnmarshalResponse .

func (*Response) GetContents

func (p *Response) GetContents() []*Generated

func (*Response) GetError

func (p *Response) GetError() string

func (*Response) GetWarnings

func (p *Response) GetWarnings() []string

func (*Response) IsSetContents

func (p *Response) IsSetContents() bool

func (*Response) IsSetError

func (p *Response) IsSetError() bool

func (*Response) IsSetWarnings

func (p *Response) IsSetWarnings() bool

func (*Response) Read

func (p *Response) Read(iprot thrift.TProtocol) error

func (*Response) ReadField1

func (p *Response) ReadField1(iprot thrift.TProtocol) error

func (*Response) ReadField2

func (p *Response) ReadField2(iprot thrift.TProtocol) error

func (*Response) ReadField3

func (p *Response) ReadField3(iprot thrift.TProtocol) error

func (*Response) String

func (p *Response) String() string

func (*Response) Write

func (p *Response) Write(oprot thrift.TProtocol) error

type Writer

type Writer interface {
	Write(oprot thrift.TProtocol) error
}

Writer writes out data to an output thrift.TProtocol.

Jump to

Keyboard shortcuts

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