Documentation
¶
Index ¶
- Variables
- func DependencyGraphTreeFormat(groups []MessageResolverGroup) string
- func ExtractIndividualErrors(err error) []error
- func ToCELType(typ *Type) *cel.Type
- type AllMessageDependencyGraph
- type AllMessageDependencyGraphNode
- type Argument
- type AutoBindField
- type CELRegistry
- type CELValue
- type ConcurrentMessageResolverGroup
- type ConstValue
- type CustomResolver
- type Enum
- type EnumRule
- type EnumValue
- type EnumValueRule
- type EnvKey
- type Error
- type Field
- type FieldOneofRule
- type FieldRule
- type File
- type Files
- type GoPackage
- type LocationError
- type Message
- func (m *Message) CustomResolverFields() []*Field
- func (m *Message) DependencyGraphTreeFormat() string
- func (m *Message) FQDN() string
- func (m *Message) Field(name string) *Field
- func (m *Message) FileName() string
- func (m *Message) GoPackage() *GoPackage
- func (m *Message) HasCELValue() bool
- func (m *Message) HasCustomResolver() bool
- func (m *Message) HasCustomResolverFields() bool
- func (m *Message) HasField(name string) bool
- func (m *Message) HasFieldRule() bool
- func (m *Message) HasRule() bool
- func (m *Message) HasRuleEveryFields() bool
- func (m *Message) Oneof(name string) *Oneof
- func (m *Message) Package() *Package
- func (m *Message) PackageName() string
- func (m *Message) ParentMessageNames() []string
- func (m *Message) ReferenceNames() []string
- func (m *Message) TypeConversionDecls() []*TypeConversionDecl
- func (m *Message) UseAllNameReference()
- type MessageDependencies
- type MessageDependency
- type MessageDependencyGraph
- type MessageDependencyGraphNode
- type MessageDependencyOwner
- type MessageDependencyOwnerType
- type MessageResolver
- type MessageResolverGroup
- type MessageResolverGroupType
- type MessageRule
- type Method
- type MethodCall
- type MethodRule
- type Oneof
- type OneofField
- type OutputFilePathConfig
- type OutputFilePathMode
- type OutputFilePathResolver
- type Package
- type ProtoFormatOption
- type Request
- type Resolver
- type Response
- type ResponseField
- type Result
- type RetryPolicy
- type RetryPolicyConstant
- type RetryPolicyExponential
- type SequentialMessageResolverGroup
- type Service
- func (s *Service) CustomResolvers() []*CustomResolver
- func (s *Service) ExistsCustomResolver() bool
- func (s *Service) FQDN() string
- func (s *Service) GoPackage() *GoPackage
- func (s *Service) GoPackageDependencies() []*GoPackage
- func (s *Service) Method(name string) *Method
- func (s *Service) Package() *Package
- func (s *Service) PackageName() string
- func (s *Service) ServiceDependencies() []*ServiceDependency
- func (s *Service) UseServices() []*Service
- type ServiceDependency
- type ServiceRule
- type Type
- type TypeConversionDecl
- type Value
- func NewBoolValue(v bool) *Value
- func NewBoolsValue(v ...bool) *Value
- func NewByteStringValue(v []byte) *Value
- func NewByteStringsValue(v ...[]byte) *Value
- func NewDoubleValue(v float64) *Value
- func NewDoublesValue(v ...float64) *Value
- func NewEnumValue(v *EnumValue) *Value
- func NewEnumsValue(v ...*EnumValue) *Value
- func NewEnvValue(v EnvKey) *Value
- func NewEnvsValue(v ...EnvKey) *Value
- func NewFixed32Value(v uint32) *Value
- func NewFixed32sValue(v ...uint32) *Value
- func NewFixed64Value(v uint64) *Value
- func NewFixed64sValue(v ...uint64) *Value
- func NewFloatValue(v float32) *Value
- func NewFloatsValue(v ...float32) *Value
- func NewInt32Value(v int32) *Value
- func NewInt32sValue(v ...int32) *Value
- func NewInt64Value(v int64) *Value
- func NewInt64sValue(v ...int64) *Value
- func NewMessageValue(typ *Type, v map[string]*Value) *Value
- func NewMessagesValue(typ *Type, v ...map[string]*Value) *Value
- func NewSfixed32Value(v int32) *Value
- func NewSfixed32sValue(v ...int32) *Value
- func NewSfixed64Value(v int64) *Value
- func NewSfixed64sValue(v ...int64) *Value
- func NewSint32Value(v int32) *Value
- func NewSint32sValue(v ...int32) *Value
- func NewSint64Value(v int64) *Value
- func NewSint64sValue(v ...int64) *Value
- func NewStringValue(v string) *Value
- func NewStringsValue(v ...string) *Value
- func NewUint32Value(v uint32) *Value
- func NewUint32sValue(v ...uint32) *Value
- func NewUint64Value(v uint64) *Value
- func NewUint64sValue(v ...uint64) *Value
- type Warning
Constants ¶
This section is empty.
Variables ¶
var ( DefaultRetryMaxRetryCount = uint64(5) DefaultRetryConstantInterval = time.Second DefaultRetryExponentialInitialInterval = 500 * time.Millisecond DefaultRetryExponentialRandomizationFactor = float64(0.5) DefaultRetryExponentialMultiplier = float64(1.5) DefaultRetryExponentialMaxInterval = 60 * time.Second )
var ( DoubleType = &Type{Type: types.Double} FloatType = &Type{Type: types.Float} Int32Type = &Type{Type: types.Int32} Int64Type = &Type{Type: types.Int64} Uint32Type = &Type{Type: types.Uint32} Uint64Type = &Type{Type: types.Uint64} Sint32Type = &Type{Type: types.Sint32} Sint64Type = &Type{Type: types.Sint64} Fixed32Type = &Type{Type: types.Fixed32} Fixed64Type = &Type{Type: types.Fixed64} Sfixed32Type = &Type{Type: types.Sfixed32} Sfixed64Type = &Type{Type: types.Sfixed64} BoolType = &Type{Type: types.Bool} StringType = &Type{Type: types.String} BytesType = &Type{Type: types.Bytes} EnumType = &Type{Type: types.Enum} EnvType = &Type{Type: types.String} DoubleRepeatedType = &Type{Type: types.Double, Repeated: true} FloatRepeatedType = &Type{Type: types.Float, Repeated: true} Int32RepeatedType = &Type{Type: types.Int32, Repeated: true} Int64RepeatedType = &Type{Type: types.Int64, Repeated: true} Uint32RepeatedType = &Type{Type: types.Uint32, Repeated: true} Uint64RepeatedType = &Type{Type: types.Uint64, Repeated: true} Sint32RepeatedType = &Type{Type: types.Sint32, Repeated: true} Sint64RepeatedType = &Type{Type: types.Sint64, Repeated: true} Fixed32RepeatedType = &Type{Type: types.Fixed32, Repeated: true} Fixed64RepeatedType = &Type{Type: types.Fixed64, Repeated: true} Sfixed32RepeatedType = &Type{Type: types.Sfixed32, Repeated: true} Sfixed64RepeatedType = &Type{Type: types.Sfixed64, Repeated: true} BoolRepeatedType = &Type{Type: types.Bool, Repeated: true} StringRepeatedType = &Type{Type: types.String, Repeated: true} BytesRepeatedType = &Type{Type: types.Bytes, Repeated: true} EnumRepeatedType = &Type{Type: types.Enum, Repeated: true} EnvRepeatedType = &Type{Type: types.String, Repeated: true} )
var DefaultProtoFormatOption = &ProtoFormatOption{IndentSpaceNum: 2}
Functions ¶
func DependencyGraphTreeFormat ¶
func DependencyGraphTreeFormat(groups []MessageResolverGroup) string
func ExtractIndividualErrors ¶
ExtractIndividualErrors extracts all error instances from Error type.
Types ¶
type AllMessageDependencyGraph ¶ added in v0.3.0
type AllMessageDependencyGraph struct {
Roots []*AllMessageDependencyGraphNode
}
func CreateAllMessageDependencyGraph ¶ added in v0.3.0
func CreateAllMessageDependencyGraph(ctx *context, msgs []*Message) *AllMessageDependencyGraph
CreateAllMessageDependencyGraph creates a dependency graph for all messages with message options defined.
type AllMessageDependencyGraphNode ¶ added in v0.3.0
type AllMessageDependencyGraphNode struct { Parent []*AllMessageDependencyGraphNode Children []*AllMessageDependencyGraphNode Message *Message }
type Argument ¶
func (*Argument) ProtoFormat ¶
func (a *Argument) ProtoFormat(opt *ProtoFormatOption, isRequestArg bool) string
type AutoBindField ¶
type AutoBindField struct { ResponseField *ResponseField MessageDependency *MessageDependency Field *Field }
func (*AutoBindField) ProtoFormat ¶
func (f *AutoBindField) ProtoFormat(opt *ProtoFormatOption) string
type CELRegistry ¶ added in v0.2.0
func (*CELRegistry) FindStructFieldType ¶ added in v0.2.0
func (r *CELRegistry) FindStructFieldType(structType, fieldName string) (*celtypes.FieldType, bool)
func (*CELRegistry) LookupEnum ¶ added in v0.2.0
func (r *CELRegistry) LookupEnum(t *celtypes.Type) (*Enum, bool)
func (*CELRegistry) RegisterFiles ¶ added in v0.2.0
func (r *CELRegistry) RegisterFiles(files ...*descriptorpb.FileDescriptorProto) error
type CELValue ¶ added in v0.2.0
type CELValue struct { Expr string Inline bool Out *Type CheckedExpr *exprv1.CheckedExpr }
func (*CELValue) ReferenceNames ¶ added in v0.3.0
type ConcurrentMessageResolverGroup ¶
type ConcurrentMessageResolverGroup struct { Starts []MessageResolverGroup End *MessageResolver }
func (*ConcurrentMessageResolverGroup) Resolvers ¶
func (g *ConcurrentMessageResolverGroup) Resolvers() []*MessageResolver
func (*ConcurrentMessageResolverGroup) Type ¶
func (g *ConcurrentMessageResolverGroup) Type() MessageResolverGroupType
type ConstValue ¶ added in v0.2.0
type ConstValue struct { Type *Type Value interface{} }
func (*ConstValue) ProtoFormat ¶ added in v0.2.0
func (c *ConstValue) ProtoFormat(opt *ProtoFormatOption) string
type CustomResolver ¶
func (*CustomResolver) FQDN ¶ added in v0.1.1
func (r *CustomResolver) FQDN() string
type Enum ¶
func (*Enum) PackageName ¶
type EnumValue ¶
type EnumValue struct { Value string Enum *Enum Rule *EnumValueRule }
type EnumValueRule ¶
type Error ¶
type Error struct {
Errs []error
}
Error represents resolver package's error. this has multiple error instances from resolver.
type Field ¶
func (*Field) HasCustomResolver ¶
func (*Field) HasMessageCustomResolver ¶
func (*Field) RequiredTypeConversion ¶
func (*Field) SourceType ¶
func (*Field) TypeConversionDecls ¶
func (f *Field) TypeConversionDecls() []*TypeConversionDecl
type FieldOneofRule ¶ added in v0.3.0
type FieldOneofRule struct { Expr *CELValue Default bool MessageDependencies MessageDependencies By *CELValue DependencyGraph *MessageDependencyGraph Resolvers []MessageResolverGroup }
FieldOneofRule represents grpc.federation.field.oneof.
type FieldRule ¶
type FieldRule struct { // Value value to bind to field. Value *Value // CustomResolver whether `custom_resolver = true` is set in grpc.federation.field option. CustomResolver bool // MessageCustomResolver whether `custom_resolver = true` is set in grpc.federation.message option. MessageCustomResolver bool // Alias valid if `alias` is specified in grpc.federation.field option. Alias *Field // AutoBindField valid if `autobind = true` is specified in resolver.response of grpc.federation.message option. AutoBindField *AutoBindField // Oneof represents oneof for field option. Oneof *FieldOneofRule }
func (*FieldRule) ProtoFormat ¶
func (r *FieldRule) ProtoFormat(opt *ProtoFormatOption) string
type File ¶
type File struct { Package *Package GoPackage *GoPackage Name string Desc *descriptorpb.FileDescriptorProto Services []*Service Messages []*Message Enums []*Enum }
func (*File) PackageName ¶
type GoPackage ¶
func ResolveGoPackage ¶
func ResolveGoPackage(def *descriptorpb.FileDescriptorProto) (*GoPackage, error)
type LocationError ¶
LocationError holds error message with location.
func ErrWithLocation ¶
func ErrWithLocation(msg string, loc *source.Location) *LocationError
ErrWithLocation creates LocationError instance from message and location.
func ToLocationError ¶
func ToLocationError(err error) *LocationError
ToLocationError convert err into LocationError if error instances the one.
func (*LocationError) Error ¶
func (e *LocationError) Error() string
type Message ¶
type Message struct { File *File Name string IsMapEntry bool ParentMessage *Message NestedMessages []*Message Enums []*Enum Fields []*Field Oneofs []*Oneof Rule *MessageRule }
func NewMessage ¶
func (*Message) CustomResolverFields ¶
func (*Message) DependencyGraphTreeFormat ¶
func (*Message) HasCELValue ¶ added in v0.2.0
func (*Message) HasCustomResolver ¶
func (*Message) HasCustomResolverFields ¶
func (*Message) HasFieldRule ¶
func (*Message) HasRuleEveryFields ¶
func (*Message) PackageName ¶
func (*Message) ParentMessageNames ¶
func (*Message) ReferenceNames ¶ added in v0.2.0
func (*Message) TypeConversionDecls ¶
func (m *Message) TypeConversionDecls() []*TypeConversionDecl
func (*Message) UseAllNameReference ¶
func (m *Message) UseAllNameReference()
type MessageDependencies ¶
type MessageDependencies []*MessageDependency
func (MessageDependencies) ProtoFormat ¶
func (deps MessageDependencies) ProtoFormat(opt *ProtoFormatOption) string
type MessageDependency ¶
type MessageDependency struct { Name string Message *Message Args []*Argument AutoBind bool Used bool Owner *MessageDependencyOwner }
func (*MessageDependency) ProtoFormat ¶
func (d *MessageDependency) ProtoFormat(opt *ProtoFormatOption) string
type MessageDependencyGraph ¶
type MessageDependencyGraph struct { MessageRule *MessageRule FieldOneofRule *FieldOneofRule Roots []*MessageDependencyGraphNode }
func CreateMessageDependencyGraph ¶
func CreateMessageDependencyGraph(ctx *context, baseMsg *Message) *MessageDependencyGraph
CreateMessageRuleDependencyGraph construct a dependency graph using the name-based reference dependencies used in the method calls and the arguments used to retrieve the dependency messages. Requires reference resolution for arguments that use prior name-based references. If a circular reference occurs, add an error to context.
func CreateMessageDependencyGraphByFieldOneof ¶ added in v0.3.0
func CreateMessageDependencyGraphByFieldOneof(ctx *context, baseMsg *Message, field *Field) *MessageDependencyGraph
func (*MessageDependencyGraph) MessageResolverGroups ¶ added in v0.3.0
func (g *MessageDependencyGraph) MessageResolverGroups(ctx *context) []MessageResolverGroup
type MessageDependencyGraphNode ¶
type MessageDependencyGraphNode struct { Parent []*MessageDependencyGraphNode Children []*MessageDependencyGraphNode ParentMap map[*MessageDependencyGraphNode]struct{} ChildrenMap map[*MessageDependencyGraphNode]struct{} BaseMessage *Message Message *Message Response *Response MessageDependency *MessageDependency }
func (*MessageDependencyGraphNode) FQDN ¶ added in v0.3.0
func (n *MessageDependencyGraphNode) FQDN() string
type MessageDependencyOwner ¶ added in v0.3.0
type MessageDependencyOwner struct { Type MessageDependencyOwnerType Message *Message Field *Field }
type MessageDependencyOwnerType ¶ added in v0.3.0
type MessageDependencyOwnerType int
const ( MessageDependencyOwnerUnknown MessageDependencyOwnerType = 0 MessageDependencyOwnerMessage MessageDependencyOwnerType = 1 MessageDependencyOwnerOneofField MessageDependencyOwnerType = 2 )
type MessageResolver ¶
type MessageResolver struct { Name string MethodCall *MethodCall MessageDependency *MessageDependency }
type MessageResolverGroup ¶
type MessageResolverGroup interface { Type() MessageResolverGroupType Resolvers() []*MessageResolver // contains filtered or unexported methods }
type MessageResolverGroupType ¶
type MessageResolverGroupType string
const ( SequentialMessageResolverGroupType MessageResolverGroupType = "sequential" ConcurrentMessageResolverGroupType MessageResolverGroupType = "concurrent" )
type MessageRule ¶
type MessageRule struct { MethodCall *MethodCall MessageDependencies MessageDependencies MessageArgument *Message DependencyGraph *MessageDependencyGraph Resolvers []MessageResolverGroup CustomResolver bool Alias *Message }
func (*MessageRule) ProtoFormat ¶
func (r *MessageRule) ProtoFormat(opt *ProtoFormatOption) string
type Method ¶
type Method struct { Service *Service Name string Request *Message Response *Message Rule *MethodRule }
func (*Method) ProtoFormat ¶
func (m *Method) ProtoFormat(opt *ProtoFormatOption) string
type MethodCall ¶
type MethodCall struct { Method *Method Request *Request Response *Response Timeout *time.Duration Retry *RetryPolicy }
func (*MethodCall) ProtoFormat ¶
func (c *MethodCall) ProtoFormat(opt *ProtoFormatOption) string
type MethodRule ¶
type Oneof ¶
func (*Oneof) IsSameType ¶ added in v0.3.0
type OneofField ¶
type OneofField struct {
*Field
}
func (*OneofField) FQDN ¶
func (f *OneofField) FQDN() string
func (*OneofField) IsConflict ¶
func (f *OneofField) IsConflict() bool
type OutputFilePathConfig ¶
type OutputFilePathConfig struct { // Mode for file output ( default: ImportMode ). Mode OutputFilePathMode // Prefix used in ModulePrefixMode. Prefix string // FilePath specify if you know the file path specified at compile time. FilePath string // ImportPaths list of import paths used during compile. ImportPaths []string }
type OutputFilePathMode ¶
type OutputFilePathMode int
const ( ImportMode OutputFilePathMode = 0 ModulePrefixMode OutputFilePathMode = 1 SourceRelativeMode OutputFilePathMode = 2 )
type OutputFilePathResolver ¶
type OutputFilePathResolver struct {
// contains filtered or unexported fields
}
func NewOutputFilePathResolver ¶
func NewOutputFilePathResolver(cfg OutputFilePathConfig) *OutputFilePathResolver
func (*OutputFilePathResolver) FileName ¶
func (r *OutputFilePathResolver) FileName(svc *Service) string
func (*OutputFilePathResolver) OutputDir ¶
func (r *OutputFilePathResolver) OutputDir(fileName string, gopkg *GoPackage) (string, error)
func (*OutputFilePathResolver) OutputPath ¶
func (r *OutputFilePathResolver) OutputPath(svc *Service) (string, error)
OutputPath returns the path to the output file. Three output mode supported by protoc-gen-go are available. FYI: https://protobuf.dev/reference/go/go-generated.
type ProtoFormatOption ¶
type Request ¶
func (*Request) ProtoFormat ¶
func (r *Request) ProtoFormat(opt *ProtoFormatOption) string
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
func New ¶
func New(files []*descriptorpb.FileDescriptorProto) *Resolver
func (*Resolver) ResolveWellknownFiles ¶
type Response ¶
type Response struct { Fields []*ResponseField Type *Message }
func (*Response) ProtoFormat ¶
func (r *Response) ProtoFormat(opt *ProtoFormatOption) string
type ResponseField ¶
func (*ResponseField) ProtoFormat ¶
func (f *ResponseField) ProtoFormat(opt *ProtoFormatOption) string
type Result ¶
type Result struct { // Services list of services that specify the grpc.federation.service option. Services []*Service // Warnings all warnings occurred during the resolve process. Warnings []*Warning }
Result of resolver processing.
type RetryPolicy ¶
type RetryPolicy struct { Constant *RetryPolicyConstant Exponential *RetryPolicyExponential }
func (*RetryPolicy) MaxRetries ¶
func (p *RetryPolicy) MaxRetries() uint64
type RetryPolicyConstant ¶
type RetryPolicyExponential ¶
type SequentialMessageResolverGroup ¶
type SequentialMessageResolverGroup struct { Start MessageResolverGroup End *MessageResolver }
func (*SequentialMessageResolverGroup) Resolvers ¶
func (g *SequentialMessageResolverGroup) Resolvers() []*MessageResolver
func (*SequentialMessageResolverGroup) Type ¶
func (g *SequentialMessageResolverGroup) Type() MessageResolverGroupType
type Service ¶
type Service struct { File *File Name string Methods []*Method Rule *ServiceRule Messages []*Message MessageArgs []*Message }
func (*Service) CustomResolvers ¶
func (s *Service) CustomResolvers() []*CustomResolver
func (*Service) ExistsCustomResolver ¶
func (*Service) GoPackageDependencies ¶
func (*Service) PackageName ¶
func (*Service) ServiceDependencies ¶
func (s *Service) ServiceDependencies() []*ServiceDependency
func (*Service) UseServices ¶
type ServiceDependency ¶
type ServiceRule ¶
type ServiceRule struct {
Dependencies []*ServiceDependency
}
type Type ¶
func NewMessageType ¶
type TypeConversionDecl ¶
func (*TypeConversionDecl) FQDN ¶
func (decl *TypeConversionDecl) FQDN() string
type Value ¶
type Value struct { CEL *CELValue Const *ConstValue }
func NewBoolValue ¶
func NewBoolsValue ¶
func NewByteStringValue ¶
func NewByteStringsValue ¶
func NewDoubleValue ¶
func NewDoublesValue ¶
func NewEnumValue ¶
func NewEnumsValue ¶
func NewEnvValue ¶
func NewEnvsValue ¶
func NewFixed32Value ¶
func NewFixed32sValue ¶
func NewFixed64Value ¶
func NewFixed64sValue ¶
func NewFloatValue ¶
func NewFloatsValue ¶
func NewInt32Value ¶
func NewInt32sValue ¶
func NewInt64Value ¶
func NewInt64sValue ¶
func NewSfixed32Value ¶
func NewSfixed32sValue ¶
func NewSfixed64Value ¶
func NewSfixed64sValue ¶
func NewSint32Value ¶
func NewSint32sValue ¶
func NewSint64Value ¶
func NewSint64sValue ¶
func NewStringValue ¶
func NewStringsValue ¶
func NewUint32Value ¶
func NewUint32sValue ¶
func NewUint64Value ¶
func NewUint64sValue ¶
func (*Value) ProtoFormat ¶
func (v *Value) ProtoFormat(opt *ProtoFormatOption) string