feat(indexer): add to modules and implement proto fields (#22544)
This commit is contained in:
@@ -46,6 +46,13 @@ func AsyncListener(opts AsyncListenerOptions, listener Listener) Listener {
|
||||
done := ctx.Done()
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
close(packetChan)
|
||||
if opts.DoneWaitGroup != nil {
|
||||
opts.DoneWaitGroup.Done()
|
||||
}
|
||||
}()
|
||||
|
||||
if opts.DoneWaitGroup != nil {
|
||||
opts.DoneWaitGroup.Add(1)
|
||||
}
|
||||
@@ -74,10 +81,6 @@ func AsyncListener(opts AsyncListenerOptions, listener Listener) Listener {
|
||||
}
|
||||
|
||||
case <-done:
|
||||
close(packetChan)
|
||||
if opts.DoneWaitGroup != nil {
|
||||
opts.DoneWaitGroup.Done()
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,10 @@ type Field struct {
|
||||
// Validate validates the field.
|
||||
func (c Field) Validate(typeSet TypeSet) error {
|
||||
// valid name
|
||||
if c.Name == "" {
|
||||
return fmt.Errorf("field name cannot be empty, might be missing the named key codec")
|
||||
}
|
||||
|
||||
if !ValidateName(c.Name) {
|
||||
return fmt.Errorf("invalid field name %q", c.Name)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func TestField_Validate(t *testing.T) {
|
||||
Name: "",
|
||||
Kind: StringKind,
|
||||
},
|
||||
errContains: "invalid field name",
|
||||
errContains: "name cannot be empty, might be missing the named key codec",
|
||||
},
|
||||
{
|
||||
name: "invalid kind",
|
||||
|
||||
@@ -53,7 +53,7 @@ func (o StateObjectType) Validate(typeSet TypeSet) error {
|
||||
|
||||
for _, field := range o.KeyFields {
|
||||
if err := field.Validate(typeSet); err != nil {
|
||||
return fmt.Errorf("invalid key field %q: %v", field.Name, err) //nolint:errorlint // false positive due to using go1.12
|
||||
return fmt.Errorf("invalid key field %q in type %q: %v", field.Name, o.Name, err) //nolint:errorlint // false positive due to using go1.12
|
||||
}
|
||||
|
||||
if !field.Kind.ValidKeyKind() {
|
||||
@@ -65,7 +65,7 @@ func (o StateObjectType) Validate(typeSet TypeSet) error {
|
||||
}
|
||||
|
||||
if fieldNames[field.Name] {
|
||||
return fmt.Errorf("duplicate field name %q", field.Name)
|
||||
return fmt.Errorf("duplicate key field name %q for stateObjectType: %s", field.Name, o.Name)
|
||||
}
|
||||
fieldNames[field.Name] = true
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func (o StateObjectType) Validate(typeSet TypeSet) error {
|
||||
}
|
||||
|
||||
if fieldNames[field.Name] {
|
||||
return fmt.Errorf("duplicate field name %q", field.Name)
|
||||
return fmt.Errorf("duplicate field name %q for stateObjectType: %s", field.Name, o.Name)
|
||||
}
|
||||
fieldNames[field.Name] = true
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ func TestObjectType_Validate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
errContains: "invalid field name",
|
||||
errContains: "field name cannot be empty, might be missing the named key codec",
|
||||
},
|
||||
{
|
||||
name: "invalid value field",
|
||||
@@ -105,7 +105,7 @@ func TestObjectType_Validate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
errContains: "invalid field name",
|
||||
errContains: "field name cannot be empty, might be missing the named key codec",
|
||||
},
|
||||
{
|
||||
name: "no fields",
|
||||
@@ -146,7 +146,7 @@ func TestObjectType_Validate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
errContains: "duplicate field name",
|
||||
errContains: "duplicate key field name \"field1\" for stateObjectType: object1",
|
||||
},
|
||||
{
|
||||
name: "nullable key field",
|
||||
|
||||
Reference in New Issue
Block a user