mirror of
https://github.com/openfaas/faas.git
synced 2025-06-20 13:06:40 +00:00
Migrate away from queue type in faas project
The queue type now resides in the provider, so that there is no risk of a circular reference. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
committed by
Alex Ellis
parent
06a51373e2
commit
58394bb1de
102
gateway/vendor/google.golang.org/protobuf/encoding/prototext/decode.go
generated
vendored
102
gateway/vendor/google.golang.org/protobuf/encoding/prototext/decode.go
generated
vendored
@ -6,14 +6,13 @@ package prototext
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/encoding/text"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/fieldnum"
|
||||
"google.golang.org/protobuf/internal/flags"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/internal/set"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
@ -23,6 +22,7 @@ import (
|
||||
)
|
||||
|
||||
// Unmarshal reads the given []byte into the given proto.Message.
|
||||
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||
func Unmarshal(b []byte, m proto.Message) error {
|
||||
return UnmarshalOptions{}.Unmarshal(b, m)
|
||||
}
|
||||
@ -51,9 +51,17 @@ type UnmarshalOptions struct {
|
||||
}
|
||||
}
|
||||
|
||||
// Unmarshal reads the given []byte and populates the given proto.Message using options in
|
||||
// UnmarshalOptions object.
|
||||
// Unmarshal reads the given []byte and populates the given proto.Message
|
||||
// using options in the UnmarshalOptions object.
|
||||
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||
func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error {
|
||||
return o.unmarshal(b, m)
|
||||
}
|
||||
|
||||
// unmarshal is a centralized function that all unmarshal operations go through.
|
||||
// For profiling purposes, avoid changing the name of this function or
|
||||
// introducing other code paths for unmarshal that do not go through this.
|
||||
func (o UnmarshalOptions) unmarshal(b []byte, m proto.Message) error {
|
||||
proto.Reset(m)
|
||||
|
||||
if o.Resolver == nil {
|
||||
@ -101,7 +109,7 @@ func (d decoder) unmarshalMessage(m pref.Message, checkDelims bool) error {
|
||||
return errors.New("no support for proto1 MessageSets")
|
||||
}
|
||||
|
||||
if messageDesc.FullName() == "google.protobuf.Any" {
|
||||
if messageDesc.FullName() == genid.Any_message_fullname {
|
||||
return d.unmarshalAny(m, checkDelims)
|
||||
}
|
||||
|
||||
@ -151,21 +159,11 @@ func (d decoder) unmarshalMessage(m pref.Message, checkDelims bool) error {
|
||||
switch tok.NameKind() {
|
||||
case text.IdentName:
|
||||
name = pref.Name(tok.IdentName())
|
||||
fd = fieldDescs.ByName(name)
|
||||
if fd == nil {
|
||||
// The proto name of a group field is in all lowercase,
|
||||
// while the textproto field name is the group message name.
|
||||
gd := fieldDescs.ByName(pref.Name(strings.ToLower(string(name))))
|
||||
if gd != nil && gd.Kind() == pref.GroupKind && gd.Message().Name() == name {
|
||||
fd = gd
|
||||
}
|
||||
} else if fd.Kind() == pref.GroupKind && fd.Message().Name() != name {
|
||||
fd = nil // reset since field name is actually the message name
|
||||
}
|
||||
fd = fieldDescs.ByTextName(string(name))
|
||||
|
||||
case text.TypeName:
|
||||
// Handle extensions only. This code path is not for Any.
|
||||
xt, xtErr = d.findExtension(pref.FullName(tok.TypeName()))
|
||||
xt, xtErr = d.opts.Resolver.FindExtensionByName(pref.FullName(tok.TypeName()))
|
||||
|
||||
case text.FieldNumber:
|
||||
isFieldNumberName = true
|
||||
@ -262,15 +260,6 @@ func (d decoder) unmarshalMessage(m pref.Message, checkDelims bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// findExtension returns protoreflect.ExtensionType from the Resolver if found.
|
||||
func (d decoder) findExtension(xtName pref.FullName) (pref.ExtensionType, error) {
|
||||
xt, err := d.opts.Resolver.FindExtensionByName(xtName)
|
||||
if err == nil {
|
||||
return xt, nil
|
||||
}
|
||||
return messageset.FindMessageSetExtension(d.opts.Resolver, xtName)
|
||||
}
|
||||
|
||||
// unmarshalSingular unmarshals a non-repeated field value specified by the
|
||||
// given FieldDescriptor.
|
||||
func (d decoder) unmarshalSingular(fd pref.FieldDescriptor, m pref.Message) error {
|
||||
@ -531,14 +520,13 @@ Loop:
|
||||
return d.unexpectedTokenError(tok)
|
||||
}
|
||||
|
||||
name := tok.IdentName()
|
||||
switch name {
|
||||
case "key":
|
||||
switch name := pref.Name(tok.IdentName()); name {
|
||||
case genid.MapEntry_Key_field_name:
|
||||
if !tok.HasSeparator() {
|
||||
return d.syntaxError(tok.Pos(), "missing field separator :")
|
||||
}
|
||||
if key.IsValid() {
|
||||
return d.newError(tok.Pos(), `map entry "key" cannot be repeated`)
|
||||
return d.newError(tok.Pos(), "map entry %q cannot be repeated", name)
|
||||
}
|
||||
val, err := d.unmarshalScalar(fd.MapKey())
|
||||
if err != nil {
|
||||
@ -546,14 +534,14 @@ Loop:
|
||||
}
|
||||
key = val.MapKey()
|
||||
|
||||
case "value":
|
||||
case genid.MapEntry_Value_field_name:
|
||||
if kind := fd.MapValue().Kind(); (kind != pref.MessageKind) && (kind != pref.GroupKind) {
|
||||
if !tok.HasSeparator() {
|
||||
return d.syntaxError(tok.Pos(), "missing field separator :")
|
||||
}
|
||||
}
|
||||
if pval.IsValid() {
|
||||
return d.newError(tok.Pos(), `map entry "value" cannot be repeated`)
|
||||
return d.newError(tok.Pos(), "map entry %q cannot be repeated", name)
|
||||
}
|
||||
pval, err = unmarshalMapValue()
|
||||
if err != nil {
|
||||
@ -590,13 +578,9 @@ Loop:
|
||||
func (d decoder) unmarshalAny(m pref.Message, checkDelims bool) error {
|
||||
var typeURL string
|
||||
var bValue []byte
|
||||
|
||||
// hasFields tracks which valid fields have been seen in the loop below in
|
||||
// order to flag an error if there are duplicates or conflicts. It may
|
||||
// contain the strings "type_url", "value" and "expanded". The literal
|
||||
// "expanded" is used to indicate that the expanded form has been
|
||||
// encountered already.
|
||||
hasFields := map[string]bool{}
|
||||
var seenTypeUrl bool
|
||||
var seenValue bool
|
||||
var isExpanded bool
|
||||
|
||||
if checkDelims {
|
||||
tok, err := d.Read()
|
||||
@ -635,12 +619,12 @@ Loop:
|
||||
return d.syntaxError(tok.Pos(), "missing field separator :")
|
||||
}
|
||||
|
||||
switch tok.IdentName() {
|
||||
case "type_url":
|
||||
if hasFields["type_url"] {
|
||||
return d.newError(tok.Pos(), "duplicate Any type_url field")
|
||||
switch name := pref.Name(tok.IdentName()); name {
|
||||
case genid.Any_TypeUrl_field_name:
|
||||
if seenTypeUrl {
|
||||
return d.newError(tok.Pos(), "duplicate %v field", genid.Any_TypeUrl_field_fullname)
|
||||
}
|
||||
if hasFields["expanded"] {
|
||||
if isExpanded {
|
||||
return d.newError(tok.Pos(), "conflict with [%s] field", typeURL)
|
||||
}
|
||||
tok, err := d.Read()
|
||||
@ -650,15 +634,15 @@ Loop:
|
||||
var ok bool
|
||||
typeURL, ok = tok.String()
|
||||
if !ok {
|
||||
return d.newError(tok.Pos(), "invalid Any type_url: %v", tok.RawString())
|
||||
return d.newError(tok.Pos(), "invalid %v field value: %v", genid.Any_TypeUrl_field_fullname, tok.RawString())
|
||||
}
|
||||
hasFields["type_url"] = true
|
||||
seenTypeUrl = true
|
||||
|
||||
case "value":
|
||||
if hasFields["value"] {
|
||||
return d.newError(tok.Pos(), "duplicate Any value field")
|
||||
case genid.Any_Value_field_name:
|
||||
if seenValue {
|
||||
return d.newError(tok.Pos(), "duplicate %v field", genid.Any_Value_field_fullname)
|
||||
}
|
||||
if hasFields["expanded"] {
|
||||
if isExpanded {
|
||||
return d.newError(tok.Pos(), "conflict with [%s] field", typeURL)
|
||||
}
|
||||
tok, err := d.Read()
|
||||
@ -667,22 +651,22 @@ Loop:
|
||||
}
|
||||
s, ok := tok.String()
|
||||
if !ok {
|
||||
return d.newError(tok.Pos(), "invalid Any value: %v", tok.RawString())
|
||||
return d.newError(tok.Pos(), "invalid %v field value: %v", genid.Any_Value_field_fullname, tok.RawString())
|
||||
}
|
||||
bValue = []byte(s)
|
||||
hasFields["value"] = true
|
||||
seenValue = true
|
||||
|
||||
default:
|
||||
if !d.opts.DiscardUnknown {
|
||||
return d.newError(tok.Pos(), "invalid field name %q in google.protobuf.Any message", tok.RawString())
|
||||
return d.newError(tok.Pos(), "invalid field name %q in %v message", tok.RawString(), genid.Any_message_fullname)
|
||||
}
|
||||
}
|
||||
|
||||
case text.TypeName:
|
||||
if hasFields["expanded"] {
|
||||
if isExpanded {
|
||||
return d.newError(tok.Pos(), "cannot have more than one type")
|
||||
}
|
||||
if hasFields["type_url"] {
|
||||
if seenTypeUrl {
|
||||
return d.newError(tok.Pos(), "conflict with type_url field")
|
||||
}
|
||||
typeURL = tok.TypeName()
|
||||
@ -691,21 +675,21 @@ Loop:
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
hasFields["expanded"] = true
|
||||
isExpanded = true
|
||||
|
||||
default:
|
||||
if !d.opts.DiscardUnknown {
|
||||
return d.newError(tok.Pos(), "invalid field name %q in google.protobuf.Any message", tok.RawString())
|
||||
return d.newError(tok.Pos(), "invalid field name %q in %v message", tok.RawString(), genid.Any_message_fullname)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fds := m.Descriptor().Fields()
|
||||
if len(typeURL) > 0 {
|
||||
m.Set(fds.ByNumber(fieldnum.Any_TypeUrl), pref.ValueOfString(typeURL))
|
||||
m.Set(fds.ByNumber(genid.Any_TypeUrl_field_number), pref.ValueOfString(typeURL))
|
||||
}
|
||||
if len(bValue) > 0 {
|
||||
m.Set(fds.ByNumber(fieldnum.Any_Value), pref.ValueOfBytes(bValue))
|
||||
m.Set(fds.ByNumber(genid.Any_Value_field_number), pref.ValueOfBytes(bValue))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user