protoeasy: go.pedge.io/protoeasy Index | Files | Directories

package protoeasy

import "go.pedge.io/protoeasy"

Package protoeasy is intended to make using protoc simpler.

Protoeasy compiles all protocol buffer files in a directory/subdirectories, taking care of all include directories, takes care of gRPC compilation, and take care of package import modifiers for Golang.

Protoeasy also provides a client/server model where compilation is delegated to a server process meant to be run in a Docker container. This allows you to not have to install protoc, gRPC, and associated protoc plugins on your local development machine.

See the README.md file for more details.

Index

Package Files

api_server.go client_compiler.go file_compile_options.go local_api_client.go plugins.go protoeasy.go protoeasy.pb.go server_compiler.go util.go var.go

Variables

var (
    //DefaultServerCompiler is the default Compiler for a server.
    DefaultServerCompiler = NewServerCompiler(CompilerOptions{})
    // DefaultAPIServer is the default API Server.
    DefaultAPIServer = NewAPIServer(DefaultServerCompiler, APIServerOptions{})
    // DefaultClientCompiler is the default Compiler for a client.
    DefaultClientCompiler = NewClientCompiler(
        NewLocalAPIClient(
            NewAPIServer(
                DefaultServerCompiler,
                APIServerOptions{
                    NoLogging: true,
                },
            ),
        ),
        CompilerOptions{},
    )
    // DefaultDescriptorSetFileName is the default descriptor set file name.
    DefaultDescriptorSetFileName = "descriptor-set.pb"
    // DefaultFileCompileOptionsFile is the default file to get FileCompileOptions from.
    DefaultFileCompileOptionsFile = "protoeasy.yaml"
    // FileCompileOptionsVersionToCompileOptionsFunc is a map from FileCompileOptions version to CompileOptions converter function.
    FileCompileOptionsVersionToCompileOptionsFunc = map[string]func(*FileCompileOptions) (*CompileOptions, error){
        "v1": toCompileOptionsV1,
    }
)
var GoPluginType_name = map[int32]string{
    0:  "GO_PLUGIN_TYPE_NONE",
    1:  "GO_PLUGIN_TYPE_GO",
    2:  "GO_PLUGIN_TYPE_GOFAST",
}
var GoPluginType_value = map[string]int32{
    "GO_PLUGIN_TYPE_NONE":   0,
    "GO_PLUGIN_TYPE_GO":     1,
    "GO_PLUGIN_TYPE_GOFAST": 2,
}
var GogoPluginType_name = map[int32]string{
    0:  "GOGO_PLUGIN_TYPE_NONE",
    1:  "GOGO_PLUGIN_TYPE_GOGO",
    2:  "GOGO_PLUGIN_TYPE_GOGOFAST",
    3:  "GOGO_PLUGIN_TYPE_GOGOFASTER",
    4:  "GOGO_PLUGIN_TYPE_GOGOSLICK",
}
var GogoPluginType_value = map[string]int32{
    "GOGO_PLUGIN_TYPE_NONE":       0,
    "GOGO_PLUGIN_TYPE_GOGO":       1,
    "GOGO_PLUGIN_TYPE_GOGOFAST":   2,
    "GOGO_PLUGIN_TYPE_GOGOFASTER": 3,
    "GOGO_PLUGIN_TYPE_GOGOSLICK":  4,
}

func AllGoPluginTypeSimpleStrings Uses

func AllGoPluginTypeSimpleStrings() []string

AllGoPluginTypeSimpleStrings returns the simple values for all GoPluginTypes.

func AllGogoPluginTypeSimpleStrings Uses

func AllGogoPluginTypeSimpleStrings() []string

AllGogoPluginTypeSimpleStrings returns the simple values for all GogoPluginTypes.

func RegisterAPIServer Uses

func RegisterAPIServer(s *grpc.Server, srv APIServer)

type APIClient Uses

type APIClient interface {
    Compile(ctx context.Context, in *CompileRequest, opts ...grpc.CallOption) (*CompileResponse, error)
}

func NewAPIClient Uses

func NewAPIClient(cc *grpc.ClientConn) APIClient

func NewLocalAPIClient Uses

func NewLocalAPIClient(apiServer APIServer) APIClient

NewLocalAPIClient returns a new APIClient that calls the APIServer directly.

type APIServer Uses

type APIServer interface {
    Compile(context.Context, *CompileRequest) (*CompileResponse, error)
}

func NewAPIServer Uses

func NewAPIServer(compiler Compiler, options APIServerOptions) APIServer

NewAPIServer returns a new APIServer for the given Compiler.

type APIServerOptions Uses

type APIServerOptions struct {
    NoLogging bool
}

APIServerOptions are options for an APIServer.

type Command Uses

type Command struct {
    Arg []string `protobuf:"bytes,1,rep,name=arg" json:"arg,omitempty"`
}

func (*Command) Descriptor Uses

func (*Command) Descriptor() ([]byte, []int)

func (*Command) GetArg Uses

func (m *Command) GetArg() []string

func (*Command) ProtoMessage Uses

func (*Command) ProtoMessage()

func (*Command) Reset Uses

func (m *Command) Reset()

func (*Command) String Uses

func (m *Command) String() string

type CompileInfo Uses

type CompileInfo struct {
    Command         []*Command                `protobuf:"bytes,1,rep,name=command" json:"command,omitempty"`
    InputSizeBytes  uint64                    `protobuf:"varint,2,opt,name=input_size_bytes,json=inputSizeBytes" json:"input_size_bytes,omitempty"`
    OutputSizeBytes uint64                    `protobuf:"varint,3,opt,name=output_size_bytes,json=outputSizeBytes" json:"output_size_bytes,omitempty"`
    Duration        *google_protobuf.Duration `protobuf:"bytes,4,opt,name=duration" json:"duration,omitempty"`
}

func (*CompileInfo) Descriptor Uses

func (*CompileInfo) Descriptor() ([]byte, []int)

func (*CompileInfo) GetCommand Uses

func (m *CompileInfo) GetCommand() []*Command

func (*CompileInfo) GetDuration Uses

func (m *CompileInfo) GetDuration() *google_protobuf.Duration

func (*CompileInfo) GetInputSizeBytes Uses

func (m *CompileInfo) GetInputSizeBytes() uint64

func (*CompileInfo) GetOutputSizeBytes Uses

func (m *CompileInfo) GetOutputSizeBytes() uint64

func (*CompileInfo) ProtoMessage Uses

func (*CompileInfo) ProtoMessage()

func (*CompileInfo) Reset Uses

func (m *CompileInfo) Reset()

func (*CompileInfo) String Uses

func (m *CompileInfo) String() string

type CompileOptions Uses

type CompileOptions struct {
    Grpc                        bool              `protobuf:"varint,1,opt,name=grpc" json:"grpc,omitempty"`
    GrpcGateway                 bool              `protobuf:"varint,2,opt,name=grpc_gateway,json=grpcGateway" json:"grpc_gateway,omitempty"`
    NoDefaultIncludes           bool              `protobuf:"varint,3,opt,name=no_default_includes,json=noDefaultIncludes" json:"no_default_includes,omitempty"`
    ExcludePattern              []string          `protobuf:"bytes,4,rep,name=exclude_pattern,json=excludePattern" json:"exclude_pattern,omitempty"`
    RelContext                  string            `protobuf:"bytes,5,opt,name=rel_context,json=relContext" json:"rel_context,omitempty"`
    ExtraPluginFlag             []string          `protobuf:"bytes,6,rep,name=extra_plugin_flag,json=extraPluginFlag" json:"extra_plugin_flag,omitempty"`
    Cpp                         bool              `protobuf:"varint,20,opt,name=cpp" json:"cpp,omitempty"`
    CppRelOut                   string            `protobuf:"bytes,21,opt,name=cpp_rel_out,json=cppRelOut" json:"cpp_rel_out,omitempty"`
    Csharp                      bool              `protobuf:"varint,30,opt,name=csharp" json:"csharp,omitempty"`
    CsharpRelOut                string            `protobuf:"bytes,31,opt,name=csharp_rel_out,json=csharpRelOut" json:"csharp_rel_out,omitempty"`
    Go                          bool              `protobuf:"varint,40,opt,name=go" json:"go,omitempty"`
    GoPluginType                GoPluginType      `protobuf:"varint,41,opt,name=go_plugin_type,json=goPluginType,enum=protoeasy.GoPluginType" json:"go_plugin_type,omitempty"`
    GoRelOut                    string            `protobuf:"bytes,42,opt,name=go_rel_out,json=goRelOut" json:"go_rel_out,omitempty"`
    GoImportPath                string            `protobuf:"bytes,43,opt,name=go_import_path,json=goImportPath" json:"go_import_path,omitempty"`
    GoNoDefaultModifiers        bool              `protobuf:"varint,44,opt,name=go_no_default_modifiers,json=goNoDefaultModifiers" json:"go_no_default_modifiers,omitempty"`
    GoModifiers                 map[string]string `protobuf:"bytes,45,rep,name=go_modifiers,json=goModifiers" json:"go_modifiers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
    Gogo                        bool              `protobuf:"varint,50,opt,name=gogo" json:"gogo,omitempty"`
    GogoPluginType              GogoPluginType    `protobuf:"varint,51,opt,name=gogo_plugin_type,json=gogoPluginType,enum=protoeasy.GogoPluginType" json:"gogo_plugin_type,omitempty"`
    GogoRelOut                  string            `protobuf:"bytes,52,opt,name=gogo_rel_out,json=gogoRelOut" json:"gogo_rel_out,omitempty"`
    GogoImportPath              string            `protobuf:"bytes,53,opt,name=gogo_import_path,json=gogoImportPath" json:"gogo_import_path,omitempty"`
    GogoNoDefaultModifiers      bool              `protobuf:"varint,54,opt,name=gogo_no_default_modifiers,json=gogoNoDefaultModifiers" json:"gogo_no_default_modifiers,omitempty"`
    GogoModifiers               map[string]string `protobuf:"bytes,55,rep,name=gogo_modifiers,json=gogoModifiers" json:"gogo_modifiers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
    Objc                        bool              `protobuf:"varint,60,opt,name=objc" json:"objc,omitempty"`
    ObjcRelOut                  string            `protobuf:"bytes,61,opt,name=objc_rel_out,json=objcRelOut" json:"objc_rel_out,omitempty"`
    Python                      bool              `protobuf:"varint,70,opt,name=python" json:"python,omitempty"`
    PythonRelOut                string            `protobuf:"bytes,71,opt,name=python_rel_out,json=pythonRelOut" json:"python_rel_out,omitempty"`
    Ruby                        bool              `protobuf:"varint,80,opt,name=ruby" json:"ruby,omitempty"`
    RubyRelOut                  string            `protobuf:"bytes,81,opt,name=ruby_rel_out,json=rubyRelOut" json:"ruby_rel_out,omitempty"`
    DescriptorSet               bool              `protobuf:"varint,90,opt,name=descriptor_set,json=descriptorSet" json:"descriptor_set,omitempty"`
    DescriptorSetRelOut         string            `protobuf:"bytes,91,opt,name=descriptor_set_rel_out,json=descriptorSetRelOut" json:"descriptor_set_rel_out,omitempty"`
    DescriptorSetFileName       string            `protobuf:"bytes,92,opt,name=descriptor_set_file_name,json=descriptorSetFileName" json:"descriptor_set_file_name,omitempty"`
    DescriptorSetIncludeImports bool              `protobuf:"varint,93,opt,name=descriptor_set_include_imports,json=descriptorSetIncludeImports" json:"descriptor_set_include_imports,omitempty"`
}

func (*CompileOptions) Descriptor Uses

func (*CompileOptions) Descriptor() ([]byte, []int)

func (*CompileOptions) GetCpp Uses

func (m *CompileOptions) GetCpp() bool

func (*CompileOptions) GetCppRelOut Uses

func (m *CompileOptions) GetCppRelOut() string

func (*CompileOptions) GetCsharp Uses

func (m *CompileOptions) GetCsharp() bool

func (*CompileOptions) GetCsharpRelOut Uses

func (m *CompileOptions) GetCsharpRelOut() string

func (*CompileOptions) GetDescriptorSet Uses

func (m *CompileOptions) GetDescriptorSet() bool

func (*CompileOptions) GetDescriptorSetFileName Uses

func (m *CompileOptions) GetDescriptorSetFileName() string

func (*CompileOptions) GetDescriptorSetIncludeImports Uses

func (m *CompileOptions) GetDescriptorSetIncludeImports() bool

func (*CompileOptions) GetDescriptorSetRelOut Uses

func (m *CompileOptions) GetDescriptorSetRelOut() string

func (*CompileOptions) GetExcludePattern Uses

func (m *CompileOptions) GetExcludePattern() []string

func (*CompileOptions) GetExtraPluginFlag Uses

func (m *CompileOptions) GetExtraPluginFlag() []string

func (*CompileOptions) GetGo Uses

func (m *CompileOptions) GetGo() bool

func (*CompileOptions) GetGoImportPath Uses

func (m *CompileOptions) GetGoImportPath() string

func (*CompileOptions) GetGoModifiers Uses

func (m *CompileOptions) GetGoModifiers() map[string]string

func (*CompileOptions) GetGoNoDefaultModifiers Uses

func (m *CompileOptions) GetGoNoDefaultModifiers() bool

func (*CompileOptions) GetGoPluginType Uses

func (m *CompileOptions) GetGoPluginType() GoPluginType

func (*CompileOptions) GetGoRelOut Uses

func (m *CompileOptions) GetGoRelOut() string

func (*CompileOptions) GetGogo Uses

func (m *CompileOptions) GetGogo() bool

func (*CompileOptions) GetGogoImportPath Uses

func (m *CompileOptions) GetGogoImportPath() string

func (*CompileOptions) GetGogoModifiers Uses

func (m *CompileOptions) GetGogoModifiers() map[string]string

func (*CompileOptions) GetGogoNoDefaultModifiers Uses

func (m *CompileOptions) GetGogoNoDefaultModifiers() bool

func (*CompileOptions) GetGogoPluginType Uses

func (m *CompileOptions) GetGogoPluginType() GogoPluginType

func (*CompileOptions) GetGogoRelOut Uses

func (m *CompileOptions) GetGogoRelOut() string

func (*CompileOptions) GetGrpc Uses

func (m *CompileOptions) GetGrpc() bool

func (*CompileOptions) GetGrpcGateway Uses

func (m *CompileOptions) GetGrpcGateway() bool

func (*CompileOptions) GetNoDefaultIncludes Uses

func (m *CompileOptions) GetNoDefaultIncludes() bool

func (*CompileOptions) GetObjc Uses

func (m *CompileOptions) GetObjc() bool

func (*CompileOptions) GetObjcRelOut Uses

func (m *CompileOptions) GetObjcRelOut() string

func (*CompileOptions) GetPython Uses

func (m *CompileOptions) GetPython() bool

func (*CompileOptions) GetPythonRelOut Uses

func (m *CompileOptions) GetPythonRelOut() string

func (*CompileOptions) GetRelContext Uses

func (m *CompileOptions) GetRelContext() string

func (*CompileOptions) GetRuby Uses

func (m *CompileOptions) GetRuby() bool

func (*CompileOptions) GetRubyRelOut Uses

func (m *CompileOptions) GetRubyRelOut() string

func (*CompileOptions) ProtoMessage Uses

func (*CompileOptions) ProtoMessage()

func (*CompileOptions) Reset Uses

func (m *CompileOptions) Reset()

func (*CompileOptions) String Uses

func (m *CompileOptions) String() string

type CompileRequest Uses

type CompileRequest struct {
    Tar            []byte          `protobuf:"bytes,1,opt,name=tar,proto3" json:"tar,omitempty"`
    CompileOptions *CompileOptions `protobuf:"bytes,2,opt,name=compile_options,json=compileOptions" json:"compile_options,omitempty"`
}

func (*CompileRequest) Descriptor Uses

func (*CompileRequest) Descriptor() ([]byte, []int)

func (*CompileRequest) GetCompileOptions Uses

func (m *CompileRequest) GetCompileOptions() *CompileOptions

func (*CompileRequest) GetTar Uses

func (m *CompileRequest) GetTar() []byte

func (*CompileRequest) ProtoMessage Uses

func (*CompileRequest) ProtoMessage()

func (*CompileRequest) Reset Uses

func (m *CompileRequest) Reset()

func (*CompileRequest) String Uses

func (m *CompileRequest) String() string

type CompileResponse Uses

type CompileResponse struct {
    Tar         []byte       `protobuf:"bytes,1,opt,name=tar,proto3" json:"tar,omitempty"`
    CompileInfo *CompileInfo `protobuf:"bytes,2,opt,name=compile_info,json=compileInfo" json:"compile_info,omitempty"`
}

func (*CompileResponse) Descriptor Uses

func (*CompileResponse) Descriptor() ([]byte, []int)

func (*CompileResponse) GetCompileInfo Uses

func (m *CompileResponse) GetCompileInfo() *CompileInfo

func (*CompileResponse) GetTar Uses

func (m *CompileResponse) GetTar() []byte

func (*CompileResponse) ProtoMessage Uses

func (*CompileResponse) ProtoMessage()

func (*CompileResponse) Reset Uses

func (m *CompileResponse) Reset()

func (*CompileResponse) String Uses

func (m *CompileResponse) String() string

type Compiler Uses

type Compiler interface {
    // Compile compiles the protocol buffer files in dirPath and outputs the generated
    // files to outDirPath, using the given CompileOptions.
    Compile(dirPath string, outDirPath string, compileOptions *CompileOptions) ([]*Command, error)
}

Compiler compiles protocol buffer files.

func NewClientCompiler Uses

func NewClientCompiler(apiClient APIClient, options CompilerOptions) Compiler

NewClientCompiler returns a new client Compiler for the given APIClient.

func NewServerCompiler Uses

func NewServerCompiler(options CompilerOptions) Compiler

NewServerCompiler returns a new server Compiler.

type CompilerOptions Uses

type CompilerOptions struct{}

CompilerOptions are options for a Compiler.

type FileCompileOptions Uses

type FileCompileOptions struct {
    Version string   `json:"version,omitempty" yaml:"version,omitempty"`
    Dir     string   `json:"dir,omitempty" yaml:"dir,omitempty"`
    Plugins []string `json:"plugins,omitempty" yaml:"plugins,omitempty"`
    Options struct {
        NoDefaultIncludes bool     `json:"no_default_includes,omitempty" yaml:"no_default_includes,omitempty"`
        Exclude           []string `json:"exclude,omitempty" yaml:"exclude,omitempty"`
        RelContext        string   `json:"rel_context,omitempty" yaml:"rel_context,omitempty"`
        Grpc              struct{} `json:"grpc,omitempty" yaml:"grpc,omitempty"`
        GrpcGateway       struct{} `json:"grpc_gateway,omitempty" yaml:"grpc_gateway,omitempty"`
        Cpp               struct {
            RelOut string `json:"rel_out,omitempty" yaml:"rel_out,omitempty"`
        }   `json:"cpp,omitempty" yaml:"cpp,omitempty"`
        Csharp struct {
            RelOut string `json:"rel_out,omitempty" yaml:"rel_out,omitempty"`
        }   `json:"csharp,omitempty" yaml:"csharp,omitempty"`
        Go  struct {
            RelOut             string            `json:"rel_out,omitempty" yaml:"rel_out,omitempty"`
            PluginType         string            `json:"plugin_type,omitempty" yaml:"plugin_type,omitempty"`
            ImportPath         string            `json:"import_path,omitempty" yaml:"import_path,omitempty"`
            NoDefaultModifiers bool              `json:"no_default_modifiers,omitempty" yaml:"no_default_modifiers,omitempty"`
            Modifiers          map[string]string `json:"modifiers,omitempty" yaml:"modifiers,omitempty"`
        }   `json:"go,omitempty" yaml:"go,omitempty"`
        Gogo struct {
            RelOut             string            `json:"rel_out,omitempty" yaml:"rel_out,omitempty"`
            PluginType         string            `json:"plugin_type,omitempty" yaml:"plugin_type,omitempty"`
            ImportPath         string            `json:"import_path,omitempty" yaml:"import_path,omitempty"`
            NoDefaultModifiers bool              `json:"no_default_modifiers,omitempty" yaml:"no_default_modifiers,omitempty"`
            Modifiers          map[string]string `json:"modifiers,omitempty" yaml:"modifiers,omitempty"`
        }   `json:"gogo,omitempty" yaml:"gogo,omitempty"`
        Objc struct {
            RelOut string `json:"rel_out,omitempty" yaml:"rel_out,omitempty"`
        }   `json:"objc,omitempty" yaml:"objc,omitempty"`
        Python struct {
            RelOut string `json:"rel_out,omitempty" yaml:"rel_out,omitempty"`
        }   `json:"python,omitempty" yaml:"python,omitempty"`
        Ruby struct {
            RelOut string `json:"rel_out,omitempty" yaml:"rel_out,omitempty"`
        }   `json:"ruby,omitempty" yaml:"ruby,omitempty"`
        DescriptorSet struct {
            RelOut         string `json:"rel_out,omitempty" yaml:"rel_out,omitempty"`
            FileName       string `json:"file_name,omitempty" yaml:"file_name,omitempty"`
            IncludeImports bool   `json:"include_imports,omitempty" yaml:"include_imports,omitempty"`
        }   `json:"descriptor_set,omitempty" yaml:"descriptor_set,omitempty"`
    }   `json:"options,omitempty" yaml:"options,omitempty"`
}

FileCompileOptions are CompileOptions with JSON and YAML tags ready to be read from a file.

func ParseFileCompileOptions Uses

func ParseFileCompileOptions(filePath string) (*FileCompileOptions, error)

ParseFileCompileOptions parses a FileCompileOptions struct from the filePath.

If file extension is .json, JSON parsing is attempted. If file extension is .yml or .yaml, YAML parsing is attemped. Otherwise, YAML parsing is first attempted, then JSON parsing.

func (*FileCompileOptions) ToCompileOptions Uses

func (f *FileCompileOptions) ToCompileOptions() (*CompileOptions, error)

ToCompileOptions converts a FileCompileOptions to a CompileOptions.

type GoPluginType Uses

type GoPluginType int32
const (
    GoPluginType_GO_PLUGIN_TYPE_NONE   GoPluginType = 0
    GoPluginType_GO_PLUGIN_TYPE_GO     GoPluginType = 1
    GoPluginType_GO_PLUGIN_TYPE_GOFAST GoPluginType = 2
)

func GoPluginTypeSimpleValueOf Uses

func GoPluginTypeSimpleValueOf(s string) (GoPluginType, error)

GoPluginTypeSimpleValueOf returns the GoPluginType for the simple value.

func (GoPluginType) EnumDescriptor Uses

func (GoPluginType) EnumDescriptor() ([]byte, []int)

func (GoPluginType) SimpleString Uses

func (x GoPluginType) SimpleString() string

SimpleString returns the simple value for the GoPluginType.

func (GoPluginType) String Uses

func (x GoPluginType) String() string

type GogoPluginType Uses

type GogoPluginType int32
const (
    GogoPluginType_GOGO_PLUGIN_TYPE_NONE       GogoPluginType = 0
    GogoPluginType_GOGO_PLUGIN_TYPE_GOGO       GogoPluginType = 1
    GogoPluginType_GOGO_PLUGIN_TYPE_GOGOFAST   GogoPluginType = 2
    GogoPluginType_GOGO_PLUGIN_TYPE_GOGOFASTER GogoPluginType = 3
    GogoPluginType_GOGO_PLUGIN_TYPE_GOGOSLICK  GogoPluginType = 4
)

func GogoPluginTypeSimpleValueOf Uses

func GogoPluginTypeSimpleValueOf(s string) (GogoPluginType, error)

GogoPluginTypeSimpleValueOf returns the GogoPluginType for the simple value.

func (GogoPluginType) EnumDescriptor Uses

func (GogoPluginType) EnumDescriptor() ([]byte, []int)

func (GogoPluginType) SimpleString Uses

func (x GogoPluginType) SimpleString() string

SimpleString returns the simple value for the GogoPluginType.

func (GogoPluginType) String Uses

func (x GogoPluginType) String() string

Directories

PathSynopsis
cmd/protoeasy
cmd/protoeasyd

Package protoeasy imports 22 packages (graph) and is imported by 2 packages. Updated 2017-04-28. Refresh now. Tools for package owners.