thriftrw: Index | Files | Directories

package plugin

import ""


Package Files

empty.go errors.go flag.go gen.go handle.go multi.go transport.go

type Flag Uses

type Flag struct {
    Name    string    // Name of the plugin
    Command *exec.Cmd // Command specification

Flag defines an external plugin specification passed over the command line.

Plugin specifications received over the command line are simply plugin names followed by arguments for the plugin.

An executable with the name thriftrw-plugin-$name is expected on the $PATH. Remaining arguments are passed to the program. For example,

-p "foo -a --bc"

Will pass the arguments "-a --bc" to the executable "thriftrw-plugin-foo".

func (*Flag) Handle Uses

func (f *Flag) Handle() (Handle, error)

Handle gets a Handle to this plugin specification.

The returned handle MUST be closed by the caller if error was nil.

func (*Flag) UnmarshalFlag Uses

func (f *Flag) UnmarshalFlag(value string) error

UnmarshalFlag parses a string specification of a plugin.

type Flags Uses

type Flags []Flag

Flags is a collection of ThriftRW external plugin specifications.

func (Flags) Handle Uses

func (fs Flags) Handle() (MultiHandle, error)

Handle gets a MultiHandle to all the plugins in this list or nil if the list is empty.

The returned handle MUST be closed by the caller if error was nil.

type Handle Uses

type Handle interface {

    // Name is the name of this plugin.
    Name() string

    // ServiceGenerator returns a ServiceGenerator for this plugin or nil if
    // this plugin does not implement that feature.
    // Note that the ServiceGenerator is valid only as long as Close is not
    // called on the Handle.
    ServiceGenerator() ServiceGenerator

Handle is a handle to ThriftRW plugin.

var EmptyHandle Handle = emptyHandle{}

EmptyHandle is a no-op Handle that does not do anything.

func NewTransportHandle Uses

func NewTransportHandle(name string, t envelope.Transport) (Handle, error)

NewTransportHandle builds a new Handle which speaks to the given transport.

If the transport is an io.Closer, it will be closed when the handle is closed.

type MultiHandle Uses

type MultiHandle []Handle

MultiHandle wraps a collection of handles into a single handle.

func (MultiHandle) Close Uses

func (mh MultiHandle) Close() error

Close closes all Handles associated with this MultiHandle.

func (MultiHandle) Name Uses

func (mh MultiHandle) Name() string

Name is the combined name of this plugin

func (MultiHandle) ServiceGenerator Uses

func (mh MultiHandle) ServiceGenerator() ServiceGenerator

ServiceGenerator returns a ServiceGenerator which calls into the ServiceGenerators of all plugins associated with this MultiHandle and consolidates their results.

type MultiServiceGenerator Uses

type MultiServiceGenerator []ServiceGenerator

MultiServiceGenerator wraps a collection of ServiceGenerators into a single ServiceGenerator.

func (MultiServiceGenerator) Generate Uses

func (msg MultiServiceGenerator) Generate(req *api.GenerateServiceRequest) (*api.GenerateServiceResponse, error)

Generate calls all the service generators associated with this plugin and consolidates their output.

Any conflicts in the generated files will result in a failure.

func (MultiServiceGenerator) Handle Uses

func (msg MultiServiceGenerator) Handle() Handle

Handle returns a reference to the Handle that owns this ServiceGenerator.

type ServiceGenerator Uses

type ServiceGenerator interface {

    // Handle returns the Handle that owns this ServiceGenerator.
    Handle() Handle

ServiceGenerator generates files for Thrift services.

var EmptyServiceGenerator ServiceGenerator = emptyServiceGenerator{}

EmptyServiceGenerator is a no-op service generator that does not generate any new files.


builtin/pluginapigenPackage pluginapigen provides a plugin Handle that generates code used by the plugin system itself.
handletestPackage handletest is a generated GoMock package.

Package plugin imports 15 packages (graph) and is imported by 14 packages. Updated 2020-01-03. Refresh now. Tools for package owners.