codegen

package
v0.16.16 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PropFilterALL = "ALL"
	PropFilterPKs = "PKs"
	PropFilterCKs = "CKs"
)

Variables

View Source
var (
	CrcBits = 64
	CrcTab  = crc64.MakeTable(crc64.ISO)
)
View Source
var (
	Commit  = "a7e6c881fdc0e264328d095a782b34f65c649895"
	Version = "v0.16.14"
)

Functions

func CrcHash added in v0.12.35

func CrcHash(data []byte) uint64

func ExecTemplate added in v0.14.3

func ExecTemplate(t *template.Template, v interface{}) string

func ZeroValue

func ZeroValue(f protoreflect.FieldDescriptor) string

ZeroValue returns the equal zero value based on the input type

Types

type ConstructorFormat added in v0.14.6

type ConstructorFormat string
const (
	StringJSON ConstructorFormat = "str"
	Int64JSON  ConstructorFormat = "int64"
)

type FieldArg

type FieldArg struct {
	ImportPath       protogen.GoImportPath
	ZeroValue        string
	Kind             string
	ProtoKind        protoreflect.Kind
	ProtoCardinality protoreflect.Cardinality
	GoKind           string
	CqlKind          string
	Cardinality      string
	HasIndex         bool
	HelpText         string
	DefaultValue     string
	// contains filtered or unexported fields
}

FieldArg holds the data needed by the template engine to generate code based on the protogen.Field

func (FieldArg) DescName added in v0.14.36

func (fa FieldArg) DescName() string

func (FieldArg) JSONName added in v0.14.36

func (fa FieldArg) JSONName() string

func (FieldArg) Name

func (fa FieldArg) Name() string

func (FieldArg) NameCC

func (fa FieldArg) NameCC() string

func (FieldArg) NameKC added in v0.12.0

func (fa FieldArg) NameKC() string

func (FieldArg) NameSC added in v0.12.0

func (fa FieldArg) NameSC() string

func (FieldArg) Options added in v0.14.13

func (fa FieldArg) Options() *descriptorpb.FieldOptions

func (FieldArg) Pkg

func (fa FieldArg) Pkg() string

func (FieldArg) Type

func (fa FieldArg) Type() string

func (FieldArg) With added in v0.12.30

func (fa FieldArg) With(f *protogen.File) FieldArg

type Generator added in v0.14.13

type Generator interface {
	Generate(out *protogen.GeneratedFile, in ...*protogen.File) error
}

type GeneratorFunc added in v0.14.13

type GeneratorFunc func(out *protogen.GeneratedFile, in ...*protogen.File) error

func (GeneratorFunc) Generate added in v0.14.13

func (f GeneratorFunc) Generate(out *protogen.GeneratedFile, in ...*protogen.File) error

type Language

type Language string
const (
	LangGo    Language = "GO"
	LangCQL   Language = "CQL"
	LangProto Language = "PROTO"
)

type MessageArg

type MessageArg struct {
	Fields     []FieldArg
	C          uint64
	ImportPath protogen.GoImportPath
	Comments   string

	// If message is representing a model then following parameters are filled
	IsAggregate bool
	IsSingleton bool
	GlobalRepo  string
	LocalRepo   string
	Table       *ModelKey
	TableExtra  []Prop
	Views       []*ModelKey
	// contains filtered or unexported fields
}

MessageArg holds the data needed by the template engine to generate code based on the protogen.Message

func GetMessageArg

func GetMessageArg(m *protogen.Message) MessageArg

func (MessageArg) CName

func (ma MessageArg) CName() string

func (MessageArg) Fullname

func (ma MessageArg) Fullname() string

func (MessageArg) IsEnvelope added in v0.15.2

func (ma MessageArg) IsEnvelope() bool

func (MessageArg) Name

func (ma MessageArg) Name() string

func (MessageArg) NameCC

func (ma MessageArg) NameCC() string

func (MessageArg) NameKC added in v0.12.0

func (ma MessageArg) NameKC() string

func (MessageArg) NameSC added in v0.12.0

func (ma MessageArg) NameSC() string

func (MessageArg) Options added in v0.14.13

func (ma MessageArg) Options() *descriptorpb.MessageOptions

func (MessageArg) Pkg

func (ma MessageArg) Pkg() string

func (MessageArg) SkipJson added in v0.16.3

func (ma MessageArg) SkipJson() bool

func (MessageArg) ViewsByPK added in v0.12.0

func (ma MessageArg) ViewsByPK() map[string][]*ModelKey

func (MessageArg) With added in v0.12.30

func (ma MessageArg) With(f *protogen.File) MessageArg

type MethodArg

type MethodArg struct {
	C           uint64
	Comments    string
	Input       MessageArg
	Output      MessageArg
	RestEnabled bool
	TunnelOnly  bool
	Rest        RestArg
	// contains filtered or unexported fields
}

MethodArg holds the data needed by the template engine to generate code based on the protogen.Method

func (MethodArg) Fullname added in v0.12.30

func (ma MethodArg) Fullname() string

func (MethodArg) Name

func (ma MethodArg) Name() string

func (MethodArg) NameCC

func (ma MethodArg) NameCC() string

func (MethodArg) NameKC

func (ma MethodArg) NameKC() string

func (MethodArg) NameSC added in v0.12.0

func (ma MethodArg) NameSC() string

func (MethodArg) Options added in v0.14.13

func (ma MethodArg) Options() *descriptorpb.MethodOptions

func (MethodArg) With added in v0.12.30

func (ma MethodArg) With(f *protogen.File) MethodArg

type ModelKey

type ModelKey struct {
	Arg *MessageArg
	// contains filtered or unexported fields
}

func (*ModelKey) Alias added in v0.12.0

func (m *ModelKey) Alias() string

func (*ModelKey) CKs

func (m *ModelKey) CKs() []Prop

func (*ModelKey) ClusteringKeys

func (m *ModelKey) ClusteringKeys() []Prop

func (*ModelKey) HasProp added in v0.12.2

func (m *ModelKey) HasProp(name string) bool

func (*ModelKey) Index added in v0.12.0

func (m *ModelKey) Index() int

func (*ModelKey) IsSubset added in v0.12.0

func (m *ModelKey) IsSubset(n *ModelKey) bool

func (*ModelKey) Keys

func (m *ModelKey) Keys() []Prop

func (*ModelKey) Name

func (m *ModelKey) Name() string

func (*ModelKey) NameTypes

func (m *ModelKey) NameTypes(filter PropFilter, namePrefix string, nameCase TextCase, lang Language) string

NameTypes is kind of strings.Join function which returns a custom format of combination of model properties. This is a helper function used in code generator templates.

func (*ModelKey) Names

func (m *ModelKey) Names(filter PropFilter, prefix, postfix string, sep string, nameCase TextCase) string

Names is kind of strings.Join function which returns a custom format of property names. This is a helper function used in code generator templates.

func (*ModelKey) PKs

func (m *ModelKey) PKs() []Prop

func (*ModelKey) PartitionKeys

func (m *ModelKey) PartitionKeys() []Prop

type Order

type Order string
const (
	ASC  Order = "ASC"
	DESC Order = "DESC"
)

type PluginOptions added in v0.12.30

type PluginOptions struct {
	NoEdgeDependency  bool
	CRC32             bool
	ConstructorFormat ConstructorFormat
	OpenAPI           bool
	ExportCleanProto  bool
}

func (*PluginOptions) ParamFunc added in v0.12.30

func (op *PluginOptions) ParamFunc(key, value string) error

type Prop

type Prop struct {
	Name      string
	ProtoType string
	CqlType   string
	GoType    string
	Order     Order
}

func (*Prop) NameSC added in v0.12.6

func (p *Prop) NameSC() string

type PropFilter

type PropFilter string

type RestArg

type RestArg struct {
	Method      string
	Path        string
	Json        bool
	Unmarshal   bool
	ExtraCode   []string
	PathParams  map[string]protoreflect.Kind
	QueryParams map[string]protoreflect.Kind
}

type ServiceArg

type ServiceArg struct {
	C            uint64
	Methods      []MethodArg
	Comments     string
	HasRestProxy bool
	// contains filtered or unexported fields
}

ServiceArg holds the data needed by the template engine to generate code based on the protogen.Service

func (ServiceArg) Name

func (sa ServiceArg) Name() string

func (ServiceArg) NameCC

func (sa ServiceArg) NameCC() string

func (ServiceArg) NameKC

func (sa ServiceArg) NameKC() string

func (ServiceArg) NameSC added in v0.12.30

func (sa ServiceArg) NameSC() string

func (ServiceArg) Options added in v0.14.13

func (sa ServiceArg) Options() *descriptorpb.ServiceOptions

func (ServiceArg) With added in v0.12.30

func (sa ServiceArg) With(f *protogen.File) ServiceArg

type TemplateArg added in v0.14.13

type TemplateArg struct {
	Messages []MessageArg
	Services []ServiceArg
}

func GenTemplateArg added in v0.14.13

func GenTemplateArg(f *protogen.File) *TemplateArg

type TextCase

type TextCase string
const (
	None           TextCase = ""
	CamelCase      TextCase = "CC"
	LowerCamelCase TextCase = "LCC"
	KebabCase      TextCase = "KC"
	SnakeCase      TextCase = "SC"
)

Jump to

Keyboard shortcuts

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